Vegeta HTTP load testing
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
echo "GET <url>" | vegeta attack | vegeta
report
vegeta attack -rate=<n> -duration=<t>
vegeta attack -targets=<file>
vegeta attack > <file>.bin
vegeta report <file>.bin
vegeta report -type=json <file>.bin
vegeta plot <file>.bin > <file>.html
vegeta encode -to=csv <file>.bin
Concepts
- Targets stdin or file
- Results binary stream
- Output text, JSON, HTML, CSV
Attack
vegeta attack-rate=<n>/<unit>
-duration=<t>
-targets=<file>
-output=<file>
-rate=0 -max-workers=<n>
-header="<Name: value>"
-body=<file>
-timeout=<t>
-workers=<n>
-max-workers=<n>
-name=<name>
-insecure-http2=false-keepalive=false
-redirects=<n>
-format=json-cert <file> -key <file>
-root-certs <files>
-connect-to <src>:<dst>
-resolvers <ip:port,...>
-dns-ttl=<t>
-connections=<n>
-lazy-chunked-h2c-unix-socket=<path>
-laddr=<ip>
-max-body=<size>
-session-tickets
-prometheus-addr=<ip:port>
Targets
# one request per block, blank line betweenGET http://localhost:8080/items?x=1X-Account-ID: 99POST http://localhost:8080/thingsContent-Type: application/json@./newthing.json
{"method":"GET","url":"http://localhost/","header":{"X-Id":["1"]},"body":"<base64>"}
Report
vegeta report <file>.bin
cat <file>.bin | vegeta report
-type=json-type=hist[0,100ms,200ms]
-type=hdrplot-every=<t>
vegeta report *.bin
| Field | Meaning |
|---|---|
| Requests | Total, rate sent, throughput |
| Latencies | Min, mean, p50/p90/p95/p99, max |
| Success | Share of 200-399 responses |
| Status Codes | Count per code; 0 = send failed |
| Error Set | Distinct errors seen |
Plot and encode
vegeta plot <file>.bin > <file>.html
vegeta plot -title=<text>
vegeta plot -threshold=<n>
vegeta plot a.bin b.bin
vegeta encode -to=csv <file>.bin
vegeta encode -to=json <file>.bin
vegeta encode -to=gob
Global
vegeta -version-cpus=<n>-profile=cpu|heap
Recipes
echo "GET http://localhost:8080/" | \ vegeta attack -rate=100 -duration=10s | \ tee results.bin | vegeta report
echo "GET http://localhost/" > t.txtvegeta attack -targets=t.txt -name=50qps -rate=50 -duration=10s > r50.binvegeta attack -targets=t.txt -name=100qps -rate=100 -duration=10s > r100.binvegeta plot r50.bin r100.bin > plot.html
jq -ncM '{method:"POST", url:"http://localhost/", body:"{}"|@base64, header:{"Content-Type":["application/json"]}}' | \ vegeta attack -format=json -rate=100 -duration=5s | vegeta report
# divide total rate by machines, run on each:vegeta attack -targets=t.txt -rate=250 -duration=60s > host1.bin# collect the files, then merge:vegeta report host*.bin



