人気の負荷試験(負荷テスト)ツールを調べてみる(Locust, Vegeta, wrk)
負荷試験(負荷テスト)ツール一覧
人気の負荷試験(負荷テスト)ツールを調べてみる。
ツール一覧はawesome-http-benchmarkにまとまってた。
スター数順に並べてみる(スター数500以上)。
wrk, Vegeta, Locustが人気のようだ。
Repository | スター数 |
---|---|
wg/wrk | 24,502 |
tsenart/vegeta | 14,504 |
locustio/locust | 12,699 |
rakyll/hey | 8,265 |
loadimpact/k6 | 6,480 |
gatling/gatling | 4,708 |
apache/jmeter | 4,079 |
JoeDog/siege | 3,997 |
mcollina/autocannon | 3,642 |
giltene/wrk2 | 2,467 |
codesenberg/bombardier | 2,069 |
processone/tsung | 1,958 |
goadapp/goad | 1,797 |
fortio/fortio | 1,291 |
httperf/httperf | 752 |
h2non/baloo | 683 |
fcsonline/drill | 540 |
パフォーマンスを比較した結果がないか探していたところ下記にまとまっていた。
下記12ツールの比較を行っており、
Hey, Vegeta, k6, Locust, wrkがよいとのこと(ユースケースによる)。
- Apachebench 2.3
- Artillery 1.6.0
- Drill 0.5.0
- Gatling 3.3.1
- Hey 0.1.2
- Jmeter 5.2.1
- k6 0.26.0
- Locust 0.13.5
- Siege 4.0.4
- Tsung 1.7.0
- Vegeta 12.7.0
- Wrk 4.1.0
人気かつパフォーマンスもよさそうなLocust, Vegeta, wrkを少し見てみる。
Locust
LocustはPython製(2011年頃からある)でpip
でインストールできる。
$ pip install locustio
テストシナリオを以下のようにPythonで書くことができ、WebベースのUIが使えるのが特徴のようだ。
from locust import HttpLocust, TaskSet, between def login(l): l.client.post("/login", {"username":"ellen_key", "password":"education"}) def logout(l): l.client.post("/logout", {"username":"ellen_key", "password":"education"}) def index(l): l.client.get("/") def profile(l): l.client.get("/profile") class UserBehavior(TaskSet): tasks = {index: 2, profile: 1} def on_start(self): login(self) def on_stop(self): logout(self) class WebsiteUser(HttpLocust): task_set = UserBehavior wait_time = between(5.0, 9.0)
Vegeta
VegetaはGo製(2014年頃からある)でバイナリのダウンロードやgo get
でインストールできる。
コマンドラインツールだけでなくライブラリとしても使えるとのこと。
$ go get -u github.com/tsenart/vegeta
Usageのexampleによると以下のように使う。
vegeta attack
というのがいいね。
examples: echo "GET http://localhost/" | vegeta attack -duration=5s | tee results.bin | vegeta report vegeta report -type=json results.bin > metrics.json cat results.bin | vegeta plot > plot.html cat results.bin | vegeta report -type="hist[0,100ms,200ms,300ms]"
vegeta plot
コマンドを使うとグラフも描けるようだ。
wrk
wrkはCで書かれており(2012年頃からある)ソースコードからmake
する。
$ wrk Usage: wrk <options> <url> Options: -c, --connections <N> Connections to keep open -d, --duration <T> Duration of test -t, --threads <N> Number of threads to use -s, --script <S> Load Lua script file -H, --header <H> Add header to request --latency Print latency statistics --timeout <T> Socket/request timeout -v, --version Print version details Numeric arguments may include a SI unit (1k, 1M, 1G) Time arguments may include a time unit (2s, 2m, 2h)
下記は12スレッド、400コネクション、30秒間負荷をかけるコマンド例。
$ wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
出力:
Running 30s test @ http://127.0.0.1:8080/index.html 12 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 635.91us 0.89ms 12.92ms 93.69% Req/Sec 56.20k 8.07k 62.00k 86.54% 22464657 requests in 30.00s, 17.76GB read Requests/sec: 748868.53 Transfer/sec: 606.33M
Luaスクリプトを読み込んで実行することもできるとのこと(スクリプト例)。