How to Install and Use Vegeta in Linux for HTTP Load Testing and Benchmarking

Stress-testing web APIs, microservices, and web servers is critical for validating whether production infrastructure can withstand peak traffic spikes without failing, throttling, or leaking memory. Many traditional load-testing tools either generate erratic bursts that fail to simulate realistic client traffic or require cumbersome GUI environments and complicated runtime configurations. Vegeta is a versatile, high-performance HTTP load-testing CLI tool and Go library built specifically for drilling HTTP services with constant, deterministic request rates.

Whether you need to fire 50 requests per second against an authentication endpoint for 30 seconds or conduct a sustained multi-hour soak test against a reverse proxy, vegeta delivers nanosecond-precision timing, detailed statistical latency percentiles (p50, p95, p99), real-time text histograms, and interactive standalone HTML/SVG latency plots. In this tutorial, you will learn how to install vegeta on Linux, define HTTP attack targets, analyze latency distributions, and export benchmark reports.

What Is Vegeta and Why Use It?

Vegeta offers distinct testing advantages over conventional tools like ApacheBench (ab) or wrk:

  • Constant Request Rate: Unlike tools that hammer servers as fast as possible in tight loops (which distorts latency as servers slow down), Vegeta maintains a strict, constant target rate (e.g. exactly 100 requests per second) to model real-world user load.
  • Versatile Target Files: Test multiple endpoints, distinct HTTP verbs (GET, POST, PUT, DELETE), custom headers, and dynamic JSON payloads in a single attack.
  • Comprehensive Latency Metrics: Outputs minimum, mean, maximum, 50th, 90th, 95th, and 99th percentile response timings with exact error codes.
  • Flexible UNIX Composability: Separates the attack phase (vegeta attack), reporting phase (vegeta report), and visualization phase (vegeta plot), enabling seamless shell piping.

Step 1: Installing Vegeta on Linux

You can install vegeta across modern Linux distributions via official static release binaries, Go, or native package managers.

Method 1: Installing via Pre-Compiled GitHub Release (Universal Linux)

The fastest deployment across Ubuntu, Debian, Fedora, Arch Linux, and Rocky Linux utilizes official GitHub binaries:

# Download the latest Linux x86_64 release tarball
curl -s https://api.github.com/repos/tsenart/vegeta/releases/latest \
  | grep "browser_download_url.*linux_amd64.tar.gz" \
  | cut -d : -f 2,3 \
  | tr -d \" \
  | wget -qi -

# Extract the archive
tar -xzf vegeta_*_linux_amd64.tar.gz

# Move binary to executable path
sudo mv vegeta /usr/local/bin/
sudo chmod +x /usr/local/bin/vegeta

Method 2: Installing via Go

If you maintain a local Go development toolchain:

go install github.com/tsenart/vegeta@latest

Method 3: Installing via Homebrew on Linux

brew install vegeta

Verify that the tool runs properly:

vegeta --version

Step 2: Executing Your First HTTP Attack

In Vegeta, a load test is called an “attack”. You can pipe an ad-hoc target directly from the command line:

echo "GET https://api.example.com/health" | vegeta attack -rate=50/s -duration=10s | vegeta report

This command instructs Vegeta to send exactly 50 requests per second to the target endpoint for 10 seconds (500 total requests) and print a consolidated ASCII report to standard output.

Interpreting the Text Report

Vegeta outputs a concise, informative statistical summary:

Requests      [total, rate, throughput]         500, 50.08, 49.95
Duration      [total, attack, wait]             10.02s, 9.98s, 40.12ms
Latencies     [min, mean, 50, 90, 95, 99, max]  12.4ms, 25.1ms, 22.8ms, 38.4ms, 45.2ms, 68.1ms, 95.3ms
Bytes In      [total, mean]                     150200, 300.40
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:500
Error Set:

Step 3: Testing Complex Endpoints with Target Files

Real-world applications require testing multiple endpoints with custom HTTP headers and JSON bodies. Create a target definition file:

nano targets.txt

Define multiple requests separated by blank lines:

GET https://api.example.com/v1/products
Accept: application/json
Authorization: Bearer mySecretToken123

POST https://api.example.com/v1/orders
Content-Type: application/json
Authorization: Bearer mySecretToken123
@data/order_payload.json

Launch the attack referencing your targets file and save raw binary results to disk for multi-format reporting:

vegeta attack -targets=targets.txt -rate=100/s -duration=30s -workers=20 > results.bin

Step 4: Generating Latency Histograms and Graphical Plots

Because you saved the raw benchmark metrics in results.bin, you can slice and display the data in multiple formats without re-running the test:

Displaying a Latency Distribution Histogram

vegeta report -type='hist[0,10ms,25ms,50ms,100ms,250ms,500ms]' results.bin

This outputs an ASCII histogram showing the exact proportion of requests resolved within each latency bucket.

Generating an Interactive HTML/SVG Latency Plot

Vegeta can generate an interactive standalone HTML plot featuring real-time zoom and pan charts:

vegeta plot results.bin > plot.html

Open plot.html in any web browser to inspect a scatter chart of individual request latencies plotted across the duration of your test.

Step 5: Testing Behind Proxies or Ignoring Self-Signed Certificates

For internal development environments running staging certificates or proxy gateways:

# Ignore self-signed TLS certificates
vegeta attack -insecure -targets=targets.txt -rate=20/s -duration=15s | vegeta report

# Route load test through an HTTP proxy
vegeta attack -proxy="http://proxy.internal:8080" -targets=targets.txt -rate=10/s | vegeta report

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.