๐Ÿ“Œ [๋ฒก์—”๋“œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธํ•˜๊ธฐ] 02. Artillery

๋ชจ๊น…ยท2024๋…„ 1์›” 8์ผ
0
post-custom-banner

๐Ÿ“– Artillery ์†Œ๊ฐœ

node.js ๋จผ์ € ๋‹ค์šด๋กœ๋“œ ํ•˜์ž.
artillery ๋‹ค์šด๋กœ๋“œ ํ•˜์ž.

npm install -g artillery@1.7.6

๐Ÿ“– Artillery๋กœ ๊ฐ„๋‹จํ•œ ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธ ์ง„ํ–‰ํ•ด๋ณด๊ธฐ

@RestController
public class SimpleController {
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String sayHello() {
        return "Hello, World!";
    }
}

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฐ„๋‹จํ•œ ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜์ž.

ํ„ฐ๋ฏธ๋„์—์„œ yamlํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์–ด๋–ค์‹์œผ๋กœ ์ง„ํ–‰ ๋  ์ง€ ๋จผ์ € ๋งŒ๋“ค์–ด๋ณด์ž.
ํ”„๋กœ์ ํŠธ ์ตœ์ƒ๋‹จ์— test-config.yaml(์„ฑ๋Šฅ ํ…Œ์ŠคํŠธ ์Šคํฌ๋ฆฝํŠธ)์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋งŒ๋“ค์ž.

config:
  target: 'http://localhost:8080'
  phases:
    - duration: 60
      arrivalRate: 5
scenarios:
  - flow:
    - get:
        url: "/hello"

ํ„ฐ๋ฏธ๋„์— ls๋ฅผ ์น˜๋ฉด

๋‹ค์Œ์ด ๋ณด์ธ๋‹ค.

- duration: 60
  arrivalRate: 5
  
  60์ดˆ ๋™์•ˆ ๋งค 1์ดˆ ๋งˆ๋‹ค 5๊ฐœ์˜ ์š”์ฒญ์„ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. -> Throughput : 5

ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์ž

artillery run --output report.json test-config.yaml

์‹คํ–‰๋œ ์ŠคํŠธ๋ ˆ์Šค ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ๋ฅผ output ํŒŒ์ผ์„ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ด๋‹ค.
report.json ์ด๋ผ๋Š” ๊ณณ์œผ๋กœ ์ด ์ŠคํŠธ๋ ˆ์Šค ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•ด์ฃผ๋ผ๋Š” ๊ฒƒ์ด๋‹ค.

Report @ 00:09:56(+0900) 2024-01-09
Elapsed time: 1 minute, 0 seconds
  Scenarios launched:  50
  Scenarios completed: 50
  Requests completed:  50
  Mean response/sec: 5
  Response time (msec):
    min: 0
    max: 1
    median: 1
    p95: 1
    p99: 1
  Codes:
    200: 50

Report @ 00:09:56(+0900) 2024-01-09
Elapsed time: 1 minute, 0 seconds
  Scenarios launched:  1
  Scenarios completed: 1
  Requests completed:  1
  Mean response/sec: 1.96
  Response time (msec):
    min: 1
    max: 1
    median: 1
    p95: 1
    p99: 1
  Codes:
    200: 1

All virtual users finished
Summary report @ 00:09:56(+0900) 2024-01-09
  Scenarios launched:  300
  Scenarios completed: 300
  Requests completed:  300
  Mean response/sec: 4.97
  Response time (msec):
    min: 0
    max: 62
    median: 1
    p95: 2
    p99: 2
  Scenario counts:
    0: 300 (100%)
  Codes:
    200: 300

min : ์ตœ์†Œ ๋ ˆ์ดํ„ด์‹œ
max : ์ตœ๋Œ€ ๋ ˆ์ดํ„ด์‹œ
median : ์ค‘๊ฐ„๊ฐ’
p95 : 95% ์‚ฌ์šฉ์ž๊ฐ€ ์–ด๋Š ์ •๋„์˜ ๋ ˆ์ดํ„ด์‹œ๋ฅผ ๋Š๋ผ๊ณ  ์žˆ๋Š”์ง€
p99 : 99% ์‚ฌ์šฉ์ž๊ฐ€ ์–ด๋Š ์ •๋„์˜ ๋ ˆ์ดํ„ด์‹œ๋ฅผ ๋Š๋ผ๊ณ  ์žˆ๋Š”์ง€
codes:200 : 200 OK ๊ฐœ์ˆ˜

1์ดˆ๋‹น 5๊ฐœ์˜ ์š”์ฒญ์ด๋ฏ€๋กœ 10์ดˆ๋™์•ˆ 50๊ฐœ 60์ดˆ ๋™์•ˆ 300๊ฐœ์˜ ์š”์ฒญ์ด ์กด์žฌํ•œ๋‹ค.

report.json ํŒŒ์ผ์ด ์ƒ๊ธด ๊ฒƒ์„ ๋ณผ์ˆ˜ ์žˆ๋‹ค.

"aggregate": {
    "timestamp": "2024-01-08T15:09:56.678Z",
    "scenariosCreated": 300,
    "scenariosCompleted": 300,
    "requestsCompleted": 300,
    "latency": {
      "min": 0,
      "max": 62,
      "median": 1,
      "p95": 2,
      "p99": 2
    },
    "rps": {
      "count": 300,
      "mean": 4.97
    },
    "scenarioDuration": {
      "min": 2.6,
      "max": 70.8,
      "median": 3.4,
      "p95": 4.7,
      "p99": 7.2
    },
    "scenarioCounts": {
      "0": 300
    },
    "errors": {},
    "codes": {
      "200": 300
    },
    "matches": 0,
    "customStats": {},
    "counters": {},
    "scenariosAvoided": 0,
    "phases": [
      {
        "duration": 60,
        "arrivalRate": 5
      }
    ]
  },
  "intermediate": [
    {
      "timestamp": "2024-01-08T15:09:06.167Z",
      "scenariosCreated": 49,
      "scenariosCompleted": 49,
      "requestsCompleted": 49,
      "latency": {
        "min": 1,
        "max": 62,
        "median": 1,
        "p95": 2,
        "p99": 62
      },
      "rps": {
        "count": 49,
        "mean": 5
      },
      "scenarioDuration": {
        "min": 3,
        "max": 70.8,
        "median": 3.5,
        "p95": 5.4,
        "p99": 70.8
      },
      "scenarioCounts": {
        "0": 49
      },
      "errors": {},
      "codes": {
        "200": 49
      },
      "matches": 0,
      "latencies": [
        62000000,
        2000000,
        2000000,
        2000000,
        2000000,
        1000000,
        2000000,
        1000000,
        2000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        2000000,
        1000000,
        1000000,
        2000000,
        1000000,
        1000000,
        1000000,
        2000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        1000000,
        2000000,
        1000000,
        1000000,
        2000000,
        2000000,
        1000000,
        2000000,
        2000000,
        1000000,
        1000000,
        2000000
      ],
      "customStats": {},
      "counters": {},
      "concurrency": 0,
      "pendingRequests": 0,
      "scenariosAvoided": 0
    }, ... ์ƒ๋žต

์šฐ๋ฆฌ๊ฐ€ ๋ณผ ์ˆ˜ ์—†์œผ๋‹ˆ HTML๋กœ ๋ฐ”๊พธ์ž! ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ž‘์„ฑํ•˜์ž.

artillery report report.json --output report.html

-> report.json ํŒŒ์ผ์„ report.html ๊ฒฝ๋กœ๋กœ ์ถœ๋ ฅ
report.html ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค!


์—ด์–ด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ html์ด ์—ด๋ฆผ!

  • summary
    • Test duration : 60์ดˆ๋กœ ์„ค์ • ํ•˜์˜€์ง€๋งŒ ์กฐ๊ธˆ ๋” ๊ฑธ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— 70์ดˆ ๋ณด์ธ๋‹ค.
    • Scenarios created : ์š”์ฒญ ์ƒ์„ฑ ๊ฐœ์ˆ˜
    • Scenarios completed : ์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต์ด ์ •์ƒ์ ์ธ ๊ฐœ์ˆ˜
  • Scenarios counts : ์‹œ๋‚˜๋ฆฌ์˜ค ๊ฐœ์ˆ˜
    • ๋ฒˆํ˜ธ๊ฐ€ ๋ถ™์Œ -> ์ด๋ฆ„์œผ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. ๋’ค์—์„œ ์•Œ์•„๋ณด์ž.
    • ์š”์ฒญ ๊ฐœ์ˆ˜
  • codes : ์‘๋‹ต์— ๋Œ€ํ•œ ์ƒํƒœ ์ฝ”๋“œ ๋ฐ ๊ฐœ์ˆ˜
  • Errors : ๋„คํŠธ์›Œํฌ๋‚˜ OS ์—๋Ÿฌ

๋งค ์ดˆ ๋งˆ๋‹ค 5๊ฐœ์˜ ์š”์ฒญ์ด ๋“ค์–ด์˜จ๋‹ค.

๋งค ์ดˆ ๋งˆ๋‹ค 5๊ฐœ์˜ ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋‹ˆ 10์ดˆ๋งˆ๋‹ค 50๊ฐœ์˜ ์š”์ฒญ์ด ๋“ค์–ด์˜จ๋‹ค.

200 OK๊ฐ€ ๋‚˜์™”๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด test-config.yaml์„ ์ˆ˜์ •ํ•ด๋ณด์ž.

config:
  target: 'http://localhost:8080'
  phases:
    - duration: 10
      arrivalRate: 5
    - duration: 10
      arrivalRate: 20
    - duration: 30
      arrivalRate: 100
    - duration: 10
      arrivalRate: 20
scenarios:
  - flow:
    - get:
        url: "/hello"

๋‹ค์Œ์„ ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰ํ•˜์ž.

artillery run --output report.json test-config.yaml

๋‹ค์Œ ์ฝ”๋“œ๋กœ ์‹คํ–‰ํ•œ HTML์„ ๋“ค์–ด๊ฐ€๋ณด์ž.

artillery report report.json --output report.html

์ด์™€ ๊ฐ™์€ ๋ณ€ํ™”๊ฐ€ ์ƒ๊ฒผ๋‹ค!




๋ณธ ํฌ์ŠคํŒ…์€ ๋ฐฑ์—”๋“œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์ฐธ๊ณ ํ•˜์—ฌ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

profile
๋ฉˆ์ถ”์ง€ ์•Š๊ธฐ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€