node.js ๋จผ์ ๋ค์ด๋ก๋ ํ์.
artillery ๋ค์ด๋ก๋ ํ์.
npm install -g artillery@1.7.6
@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์ด ์ด๋ฆผ!
๋งค ์ด ๋ง๋ค 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
์ด์ ๊ฐ์ ๋ณํ๊ฐ ์๊ฒผ๋ค!
๋ณธ ํฌ์คํ ์ ๋ฐฑ์๋ ์ ํ๋ฆฌ์ผ์ด์ ์ฑ๋ฅ ํ ์คํธํ๊ธฐ ์ฐธ๊ณ ํ์ฌ ์์ฑํ์์ต๋๋ค.