서버 구축을 완료한 후 운영서버에 배포하기 전에 성능테스트가 필요하다. API서버, 웹어플리케이션서버를 구축한 후 성능테스틑 진행하는데 서버가 얼마만큼의 부하를 견딜 수 있는지 테스트하는 것이다. 이를 통해 병목 지점을 찾을 수도 있고 얼마만큼의 트래픽을 수용할 수 있는지도 확인을 할 수가 있다. 이를 통해 사용자 증가에 따른 서버의 증설도 고려할 수 있고, 이벤트 상황에도 조금 더 유연하게 대처할 수 있을 것이다.
1. Artillery 설치하기
위 링크에 Artillery 를 설치 하는 방법이 있으니 필요 시 참고 할 수 있다.
yul@yul-pro ] npm
zsh: command not found: npm
yul@yul-pro ] brew install npm
Running `brew update --preinstall`...
yul@yul-pro ] npm install -D artillery@latest
설치 후 확인
yul@yul-pro ] artillery --version
___ __ _ ____
_____/ | _____/ /_(_) / /__ _______ __ ___
/____/ /| | / ___/ __/ / / / _ \/ ___/ / / /____/
/____/ ___ |/ / / /_/ / / / __/ / / /_/ /____/
/_/ |_/_/ \__/_/_/_/\___/_/ \__ /
/____/
VERSION INFO:
Artillery Core: 2.0.0-23
Artillery Pro: not installed (https://artillery.io/product)
Node.js: v18.9.0
OS: darwin
2. 단일 호출과 시나리오 호출 방법
단일호출
yul@yul-pro ] artillery quick --count 10 -n 10 http://dev-api.test.net/test/v1/config/web
시나리오 호출
{
"config": {
"target": "http://dev-api.test.net",
"phases": [
{
"duration": 10,
"arrivalRate": 10
}
],
"defaults" : {
"headers" : {
"Authorization" : "dd133MtYTkwYTY4YmFkMzZiIiwic2VxIjoxNDQxODEyLCJpYXQi.rOXCgozPdW3ic0E"
}
}
},
"scenarios": [
{
"flow": [
{
"get": {
"url": "/test/v1/config/web"
}
},
{
"get": {
"url": "/test/v1/me"
}
}
]
}
]
}
3. 결과 확인
yul@yul-pro ] artillery quick --count 10 -n 10 http://dev-api.test.net/test/v1/config/web
Running scenarios...
Phase started: unnamed (index: 0, duration: 1s) 18:42:44(+0900)
Phase completed: unnamed (index: 0, duration: 1s) 18:42:45(+0900)
--------------------------------------
Metrics for period to: 18:42:50(+0900) (width: 5.501s)
--------------------------------------
http.codes.200: ................................................................ 37
http.request_rate: ............................................................. 9/sec
http.requests: ................................................................. 47
http.response_time:
min: ......................................................................... 149
max: ......................................................................... 3310
median: ...................................................................... 854.2
p95: ......................................................................... 3328.3
p99: ......................................................................... 3328.3
http.responses: ................................................................ 37
vusers.created: ................................................................ 10
vusers.created_by_name.0: ...................................................... 10
yul@yul-pro ] artillery run artillery_default.json
Running scenarios...
Phase started: unnamed (index: 0, duration: 10s) 18:43:33(+0900)
Phase completed: unnamed (index: 0, duration: 10s) 18:43:43(+0900)
--------------------------------------
Metrics for period to: 18:43:40(+0900) (width: 5.858s)
--------------------------------------
http.codes.200: ................................................................ 27
http.request_rate: ............................................................. 17/sec
http.requests: ................................................................. 76
http.response_time:
min: ......................................................................... 82
max: ......................................................................... 3956
median: ...................................................................... 871.5
p95: ......................................................................... 3605.5
p99: ......................................................................... 3905.8
http.responses: ................................................................ 27
vusers.completed: .............................................................. 10
vusers.created: ................................................................ 59
vusers.created_by_name.0: ...................................................... 59
vusers.failed: ................................................................. 0
vusers.session_length:
min: ......................................................................... 209.5
max: ......................................................................... 5061
median: ...................................................................... 1326.4
p95: ......................................................................... 4492.8
p99: ......................................................................... 4492.8
테스트가 완료되면 위와 같이 결과를 조회할 수 있다.
또한 report 명령어를 사용하면 보기 쉽게 html 로 볼 수도 있다.
작업환경 : mac, spring boot