Ir al contenido

Comandos de bombardier

bombardier es una herramienta de benchmarking HTTP rápida y multiplataforma escrita en Go. Proporciona estadísticas de latencia detalladas, soporta HTTP/1.x y HTTP/2, y ofrece varios controles de limitación de velocidad.

Instalación

# Go install
go install github.com/codesenberg/bombardier@latest

# macOS
brew install bombardier

# Download prebuilt binary (Linux amd64)
curl -sSfL https://github.com/codesenberg/bombardier/releases/latest/download/bombardier-linux-amd64 \
  -o /usr/local/bin/bombardier
chmod +x /usr/local/bin/bombardier

# Docker
docker run --rm alpine/bombardier -c 100 -d 30s http://host.docker.internal:8080/

# Verify
bombardier --version

Uso básico

# Simple test with defaults (125 connections, 10 seconds)
bombardier http://localhost:8080/

# Specify number of total requests
bombardier -n 10000 http://localhost:8080/

# Specify duration
bombardier -d 30s http://localhost:8080/

# Specify both connections and duration
bombardier -c 200 -d 60s http://localhost:8080/

Modo de conteo de solicitudes

# Send exactly N requests
bombardier -n 1000 http://localhost:8080/

# With specific concurrency
bombardier -n 5000 -c 50 http://localhost:8080/

# Quick smoke test
bombardier -n 10 -c 1 http://localhost:8080/health

Modo de duración

# Run for a specific time period
bombardier -d 10s http://localhost:8080/   # 10 seconds
bombardier -d 5m http://localhost:8080/    # 5 minutes
bombardier -d 1h http://localhost:8080/    # 1 hour

# Common test durations
bombardier -c 100 -d 30s http://localhost:8080/  # Standard
bombardier -c 500 -d 60s http://localhost:8080/  # Stress
bombardier -c 1000 -d 5m http://localhost:8080/  # Sustained load

Limitación de tasa

# Limit to specific requests per second
bombardier -r 100 -d 60s http://localhost:8080/
# Sends exactly 100 requests per second for 60 seconds

# Rate limit with concurrency
bombardier -c 50 -r 500 -d 60s http://localhost:8080/
# 50 connections targeting 500 RPS

# Low-rate soak test
bombardier -c 10 -r 10 -d 10m http://localhost:8080/
# 10 RPS for 10 minutes (steady-state monitoring)

Conexiones concurrentes

# Light load
bombardier -c 10 -d 30s http://localhost:8080/

# Medium load
bombardier -c 100 -d 30s http://localhost:8080/

# Heavy load
bombardier -c 500 -d 30s http://localhost:8080/

# Maximum stress
bombardier -c 2000 -d 60s http://localhost:8080/

Timeouts

# Set request timeout (default: 2s)
bombardier -t 5s -c 100 -d 30s http://localhost:8080/

# Long timeout for slow endpoints
bombardier -t 30s -c 50 -d 60s http://localhost:8080/api/heavy-computation

# Short timeout for health checks
bombardier -t 500ms -c 10 -n 100 http://localhost:8080/health

Encabezados personalizados

# Add custom headers
bombardier -H "Authorization: Bearer token123" http://localhost:8080/api

# Multiple headers
bombardier -H "Authorization: Bearer token123" \
           -H "Accept: application/json" \
           -H "X-Custom-Header: value" \
           http://localhost:8080/api

# Custom User-Agent
bombardier -H "User-Agent: bombardier-loadtest" http://localhost:8080/

Métodos HTTP y cuerpo

# POST with body
bombardier -m POST -b '{"key":"value"}' \
    -H "Content-Type: application/json" \
    http://localhost:8080/api/items

# POST with body from file
bombardier -m POST -f payload.json \
    -H "Content-Type: application/json" \
    http://localhost:8080/api/items

# PUT request
bombardier -m PUT -b '{"name":"updated"}' \
    -H "Content-Type: application/json" \
    http://localhost:8080/api/items/1

# DELETE request
bombardier -m DELETE http://localhost:8080/api/items/1

# PATCH request
bombardier -m PATCH -b '{"status":"active"}' \
    -H "Content-Type: application/json" \
    http://localhost:8080/api/items/1

Histograma de latencia

# Print latency distribution
bombardier -l -c 100 -d 30s http://localhost:8080/

# Output includes histogram like:
# Latency
#    50%   1.23ms
#    75%   2.45ms
#    90%   5.12ms
#    95%   8.34ms
#    99%  15.67ms

Formatos de salida

# JSON output (for scripting and analysis)
bombardier -o json -c 100 -d 30s http://localhost:8080/ > results.json

# JSON output to stdout (parseable)
bombardier -p r -o json -c 100 -n 1000 http://localhost:8080/

# Parse JSON results with jq
bombardier -o json -c 100 -d 30s http://localhost:8080/ | \
    python3 -c "import sys,json; d=json.load(sys.stdin); \
    print(f'RPS: {d[\"result\"][\"rps\"][\"mean\"]:.0f}'); \
    print(f'Latency avg: {d[\"result\"][\"latency\"][\"mean\"]/1e6:.2f}ms')"

# Plain text output (default)
bombardier -p r -c 100 -d 30s http://localhost:8080/

Opciones de impresión

# Control output verbosity
bombardier -p r http://localhost:8080/  # Result only (no progress bar)
bombardier -p i http://localhost:8080/  # Introductory info only
bombardier -p b http://localhost:8080/  # Progress bar only (default)

TLS y HTTP/2

# HTTPS endpoint
bombardier https://example.com/

# Skip TLS verification
bombardier -k https://localhost:8443/

# Force HTTP/1.1
bombardier --http1 https://example.com/

# Use HTTP/2 (default for HTTPS)
bombardier --http2 https://example.com/

Patrones de prueba comunes

# Quick health check
bombardier -n 5 -c 1 http://localhost:8080/health

# Baseline performance
bombardier -c 1 -d 30s -l http://localhost:8080/

# Scaling test
for c in 1 10 50 100 200 500; do
    echo "=== $c connections ==="
    bombardier -c $c -d 15s -p r -l http://localhost:8080/
    sleep 2
done

# Soak test (long duration, moderate load)
bombardier -c 50 -r 200 -d 30m http://localhost:8080/

# Spike test (sudden high load)
bombardier -c 1000 -d 10s http://localhost:8080/

# Endpoint comparison
for path in /api/v1/users /api/v1/items /api/v1/search; do
    echo "=== $path ==="
    bombardier -c 100 -d 15s -p r http://localhost:8080$path
done

Lectura de salida

# Example bombardier output:
# Bombarding http://localhost:8080/ for 30s using 100 connections
# [==============================] 30s
# Done!
# Statistics        Avg      Stdev        Max
#   Reqs/sec     18523.45   1234.56   22145.00
#   Latency        5.39ms     2.12ms    48.23ms
#   HTTP codes:
#     1xx - 0, 2xx - 555703, 3xx - 0, 4xx - 0, 5xx - 0
#     others - 0
#   Throughput:    42.15MB/s

# Key metrics to watch:
# - Reqs/sec Avg: overall throughput
# - Latency Avg: mean response time
# - Latency Stdev: consistency (lower is better)
# - HTTP codes: check for 4xx/5xx errors
# - others: connection errors, timeouts