Spring Boot/환경설정

artillery로 부하테스트 하기

sendkite 2023. 10. 29. 01:49

1. 설치

// 설치
npm install -g artillery@latest

// 설치 확인
artillery version

2. 사용법 : https://www.artillery.io/docs/reference/cli/run

// 터미널에서 바로 실행하기
 artillery quick --count 100 -n 50 http://localhost:8080/health
 
 // script로 실행하기
 artillery run test.yaml
 
 // json 파일로도 실행할 수 있다.
 artillery run test.json
 
 // 테스트 결과 report로 만들기
 artillery run --output test-run-report.json test.json
 
 // 테스트 결과 report html로 보기
 artillery report test-run-report

- test.json 예시

{
  "config": {
     "target": "http://localhost:8080",
     "phases": [
        {
           "duration": 60,
           "arrivalRate": 60
        }
     ]
  },
  "scenarios": [
     {
        "flow": [
           {
              "get": {
                 "url": "/health"
              }
           },
           {
              "post": {
                 "url": "/posts",
                 "json": {
                    "title": "hello",
                    "content": "world"
                 }
              }
           },
           {
              "get": {
                 "url": "/posts"
              }
           }
        ]
     }
  ]
}
반응형