# Vegeta — HTTP Load Testing Tool at Constant Request Rates > Fast Go HTTP load generator that sustains a precise constant request rate and emits HDR histograms, JSON reports, and latency plots. ## Install Save in your project root: # Vegeta — HTTP Load Testing at Constant Rate ## Quick Use ```bash # Install brew install vegeta # or: go install github.com/tsenart/vegeta/v12@latest # 500 requests/sec for 30s, then a report and a latency plot echo "GET https://httpbin.org/get" | vegeta attack -rate=500 -duration=30s | tee results.bin | vegeta report vegeta plot results.bin > latencies.html ``` ## Introduction Vegeta is a small but sharply focused HTTP load testing tool written in Go. Unlike tools that only generate "as much traffic as possible", Vegeta attacks at a precise, constant request rate — the workload model that actually matches production behavior — and produces latency histograms, time series, and JSON reports you can drop into CI. ## What Vegeta Does - Sustains a user-specified constant request rate across long runs. - Reads targets from stdin, a file, or an HTTP/2 source for dynamic payloads. - Produces text, JSON, HDR-histogram, and interactive HTML latency plots. - Runs in library mode from Go code for scripted load tests. - Supports HTTP/2, custom headers, body templates, TLS client certs, and proxies. ## Architecture Overview Vegeta separates the attacker (generator), the encoder (writes results to disk), and the reporter (reads and summarizes). It uses Go goroutines to issue requests on a fixed time grid (`rate = requests / duration`). Results are captured as gob-encoded records, streamed to a file so runs are cheap in RAM. Reports, plots, and HDR dumps are derived offline from the same result file, so you can re-analyze a single run many ways. ## Self-Hosting & Configuration - Distribute via Homebrew, Nix, Docker (`ghcr.io/tsenart/vegeta`), or plain Go install. - Use a targets file: each target is `METHOD URL`, optionally followed by headers and `@body_file`. - Tune `-workers`, `-connections`, `-max-connections`, and `-timeout` for high-concurrency scenarios. - Increase OS-level `ulimit -n` and ephemeral port range before attacking above ~20k RPS. - Export to Prometheus via the `vegeta report -type=json` output and a simple shim, or use the built-in HDR histogram. ## Key Features - Open-model load generation (constant rate) rather than closed-loop ramp-ups. - HDR latency histograms with microsecond resolution. - Pluggable encoders and library API for programmatic attacks. - Interactive latency-over-time HTML plot built in. - Small, single static binary — fits into Alpine CI images cleanly. ## Comparison with Similar Tools - **k6** — scriptable JS tests and cloud product; Vegeta is CLI-first and simpler. - **wrk/wrk2** — highest raw throughput, but weaker reporting. - **hey** — simpler, no HDR histograms or plots. - **Locust** — Python DSL and great for complex flows; Vegeta focuses on raw HTTP rate tests. - **JMeter** — GUI-heavy and JVM-based; Vegeta is a single Go binary. ## FAQ **Q:** Can I drive dynamic bodies and headers? A: Yes. Targets files support body files per target, and you can re-generate them between runs. **Q:** Does Vegeta support HTTP/2 and gRPC? A: HTTP/2, yes. For gRPC, use ghz — a gRPC-specific tool with a similar design. **Q:** How do I run Vegeta in CI without false positives? A: Warm up the target first, then run a short Vegeta attack and fail on p99 latency or success-rate thresholds. **Q:** Can it replay production traffic? A: Use goreplay or tcpcopy to capture, then feed the resulting target file into Vegeta. ## Sources - https://github.com/tsenart/vegeta - https://pkg.go.dev/github.com/tsenart/vegeta/v12 --- Source: https://tokrepo.com/en/workflows/b048c0d2-38d6-11f1-9bc6-00163e2b0d79 Author: AI Open Source