0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vegetaメモ

Posted at

概要

vegeta とは、golang製のhttp負荷検証ツール。

できること

  • 負荷をかける(atack)
  • 実行結果レポートの出力(report)
  • dumpもできるが、実例少なめ?

導入

homebrewで入れられる。

$ brew update
$ brew install vegeta

$ vegeta -h   # vegeta コマンドのヘルプが表示できるかを確認

実行

ワンライナーでとりあえず実行してみる。
対象URLを出力 > 負荷検証の値を指定 > 結果レポート出力

$ echo "GET http://localhost/" | ./vegeta attack --insecure -cpu 8 rate=10 -duration=60s | ./vegeta report

atack

対象をテキストで事前準備しておくと検証しやすい。

# ターゲットを指定したテキストを事前準備
$ cat targets.txt
  
# ターゲットに対して負荷をかける
$ vegeta attack -insecure -cpu 8 -rate 10 -duration 60s -targets targets.txt  > report.out

負荷テストの結果はそのままでは表示できず、別ファイルに一旦出力する必要がある。

report

atack の出力ファイルを指定し、任意の形式で表示することができる。

# 出力したレポートをテキストベースで表示
$ vegeta report -inputs=report.out
$ vegeta report -inputs=report.out -reporter=text
Requests      [total, rate]            1, 1.00
Duration      [total, attack, wait]    42.156345ms, 0s, 42.156345ms
Latencies     [mean, 50, 95, 99, max]  42.156345ms, 42.156345ms, 42.156345ms, 42.156345ms, 42.156345ms
Bytes In      [total, mean]            262, 262.00
Bytes Out     [total, mean]            0, 0.00
Success       [ratio]                  100.00%
Status Codes  [code:count]             200:1
Error Set:
 
# jsonベースで表示
$ vegeta report -inputs=report.out -reporter=json | jq
{
  "latencies": {
    "total": 42156345,
    "mean": 42156345,
    "50th": 42156345,
    "95th": 42156345,
    "99th": 42156345,
    "max": 42156345
  },
  "bytes_in": {
    "total": 262,
    "mean": 262
  },
  "bytes_out": {
    "total": 0,
    "mean": 0
  },
  "earliest": "2018-04-19T17:29:29.931859+09:00",
  "latest": "2018-04-19T17:29:29.931859+09:00",
  "end": "2018-04-19T17:29:29.974015345+09:00",
  "duration": 0,
  "wait": 42156345,
  "requests": 1,
  "rate": 1,
  "success": 1,
  "status_codes": {
    "200": 1
  },
  "errors": null
}
 
# html形式でプロット表示
$ vegeta report -inputs=report.out -reporter=plot > plot.html
$ open plot.html
 
# 指定間隔のヒストグラムで表示
$ vegeta report -inputs=report.out -reporter='hist[0,10ms,20ms,40ms,60ms,80ms,100ms,200ms,300ms,400ms,500ms,600ms,700ms,800ms,900ms,1000ms,3000ms,5000ms,10000ms,15000ms,30000ms]'
Bucket           #  %        Histogram
[0s,     10ms]   0  0.00%
[10ms,   20ms]   0  0.00%
[20ms,   40ms]   0  0.00%
[40ms,   60ms]   1  100.00%  ###########################################################################
[60ms,   80ms]   0  0.00%
[80ms,   100ms]  0  0.00%
[100ms,  200ms]  0  0.00%
[200ms,  300ms]  0  0.00%
[300ms,  400ms]  0  0.00%
[400ms,  500ms]  0  0.00%
[500ms,  600ms]  0  0.00%
[600ms,  700ms]  0  0.00%
[700ms,  800ms]  0  0.00%
[800ms,  900ms]  0  0.00%
[900ms,  1s]     0  0.00%
[1s,     3s]     0  0.00%
[3s,     5s]     0  0.00%
[5s,     10s]    0  0.00%
[10s,    15s]    0  0.00%
[15s,    30s]    0  0.00%
[30s,    +Inf]   0  0.00%
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?