APACHE BENCH (AB) CHEAT SHEET

HTTP Server Benchmarking Tool
v1.0
Installation
  • apt install apache2-utilsUbuntu/Debian
  • yum install httpd-toolsCentOS/RHEL
  • brew install httpdmacOS
  • ab -VCheck version
Basic Syntax
# Basic syntax: ab [options] URL ab -n 1000 -c 100 http://example.com/ # URL MUST end with / for root path ab -n 500 -c 50 http://example.com/api/users/ # With keep-alive connections ab -n 1000 -c 100 -k http://example.com/
Essential Options
  • -nTotal requests
  • -cConcurrent requests
  • -tTimelimit (seconds)
  • -kEnable keep-alive
  • -sTimeout (default 30)
  • -vVerbosity level (1-4)
Request Options
  • -HAdd header
  • -TContent-Type
  • -pPOST data file
  • -uPUT data file
  • -mHTTP method
  • -CCookie (name=val)
Authentication
  • -A user:passBasic auth
  • -P user:passProxy auth
  • -X proxy:portUse proxy
  • -H "Auth: ..."Custom header
SSL/TLS Options
  • -f protocolSSL/TLS protocol
  • -Z ciphersuiteSpecify cipher
  • -E certfileClient certificate
  • SSL2, SSL3, TLS1Protocol values
Common Examples
# Simple GET test (1000 requests, 10 concurrent) ab -n 1000 -c 10 http://localhost:8080/ # POST with JSON data ab -n 500 -c 50 -p data.json -T "application/json" http://api.com/users/ # With auth header and keep-alive ab -n 1000 -c 100 -k -H "Authorization: Bearer token123" http://api.com/ # Time-based test (run for 60 seconds) ab -t 60 -c 100 http://example.com/
Output Metrics Explained
  • Requests per secondThroughput (RPS)
  • Time per requestMean response time (ms)
  • Transfer rateKB/sec received
  • ConnectTCP connection time
  • ProcessingServer processing time
  • WaitingTime to first byte (TTFB)
  • Failed requestsNon-2xx responses
  • Percentage servedLatency percentiles
Output Options
  • -g file.tsvGnuplot output
  • -e file.csvCSV percentages
  • -qQuiet (no progress)
  • -v 2Show warnings
  • -v 4Show headers
Limitations
  • Single URL onlyNo URL rotation
  • Single threadLimited scaling
  • No scriptingStatic requests
  • Basic metricsLimited stats