CentOs8 負荷テストツール「Vegeta」をインストールして実行する

CentOs8 負荷テストツール「Vegeta」をインストールして実行する

CentOs8にgo言語で記述された負荷テストツール「Vegeta(ベジータ)」をインストールして実行するまでの手順を記述してます。

環境

  • OS  CentOS Linux release 8.2.2004 (Core)
  • go 1.13.1

※CentOs8にGo言語のインストール手順はこちら

Vegetaインストール

下記のコマンドのみでインストール可能です。

go get -u github.com/tsenart/vegeta

Vegeta使い方

1秒間に5リクエスト[ -rate=5 ]
5秒間 [ -duration=5s ]
で実行してみます。

echo "GET http://対象のアドレス/" | vegeta attack -rate=5 -duration=5s | tee result.bin

テスト結果は「result.bin」に保存されます。

result.binをテキスト形式で確認してみます。

vegeta report -type=text result.bin

<出力結果>
Requests      [total, rate, throughput]         25, 5.21, 5.19
Duration      [total, attack, wait]             4.819s, 4.8s, 18.861ms
Latencies     [min, mean, 50, 90, 95, 99, max]  9.979ms, 13.059ms, 12.494ms, 18.861ms, 19.02ms, 19.029ms, 19.029ms
Bytes In      [total, mean]                     93025, 3721.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:25  
Error Set:

json形式[ -type=json ]と指定すれば、jsonで確認できます。

vegeta report -type=json result.bin

<出力結果>
{"latencies":{"total":326477973,"mean":13059118,"50th":12493888,"90th":18861267,"95th":19020302,"99th":19028891,"max":19028891,"min":9979237},"bytes_in":{"total":93025,"mean":3721},"bytes_out":{"total":0,"mean":0},"earliest":"2020-07-16T11:59:01.771238848+09:00","latest":"2020-07-16T11:59:06.571191264+09:00","end":"2020-07-16T11:59:06.590052531+09:00","duration":4799952416,"wait":18861267,"requests":25,"rate":5.2083849657896275,"throughput":5.187998882006163,"success":1,"status_codes":{"200":25},"errors":[]}

html化してグラフでみることも可能です。

cat result.bin | vegeta plot > plot.html