[vegeta] 부하 테스트

2023. 11. 14. 15:02

 

vegeta를 사용해 api 부하 테스트를 진행하려 한다.

 

vegeta 설치 (Mac OS)

brew update && brew install vegeta

 

vegeta 스크립트 작성

'@payload.json'은 POST 요청에 사용할 JSON payload를 담고 있는 파일 경로

해당 파일을 작성하고 적절한 JSON 데이터를 추가해야 함

# attack-rate-script.txt

POST http://host:port/api-name/
Content-Type: application/json
@payload.json

json payload.json 작성

# payload.json 예시

{
  "key1": "value1",
  "key2": "value2",
  ...
}

vegeta 실행

아래 예시는 duration 60초 동안 1초에 요청 5개씩 (rate=5) 보내는 것이다

vegeta attack -targets=attack-rate-script.txt -duration=60s -rate=5 --output results.bin; vegeta report results.bin

이후 아래 명령어로 plot을 볼 수 있다.

cat results.bin| vegeta plot > plot.results.html

 

 

json으로 결과를 볼 수도 있다.

vegeta attack -targets=attack-rate-script.txt -duration=60s -rate=5 | vegeta report -type=json > result.json

 

 

 

 

 

 

 

 

 

 

https://github.com/tsenart/vegeta

 

GitHub - tsenart/vegeta: HTTP load testing tool and library. It's over 9000!

HTTP load testing tool and library. It's over 9000! - GitHub - tsenart/vegeta: HTTP load testing tool and library. It's over 9000!

github.com