ab
Benchmark HTTP server performance
TLDR
Execute 100 HTTP GET requests to a given URL
Execute 100 HTTP GET requests, in concurrent batches of 10, to a URL
Execute 100 HTTP POST requests to a URL, using a JSON payload from a file
Use HTTP [k]eep-Alive, i.e. perform multiple requests within one HTTP session
Set the maximum number of seconds ([t]imeout) to spend for benchmarking (30 by default)
Write the results to a CSV file
SYNOPSIS
ab [options] [http://]hostname[:port]/path
PARAMETERS
-n requests
Number of requests to perform for the benchmarking session.
-c concurrency
Number of multiple requests to make at a time. Simulates concurrent users.
-t timelimit
Maximum seconds to spend on benchmarking. Defaults to no limit.
-p postfile
File containing data to POST. Remember also to set -T.
-u putfile
File containing data to PUT. Remember also to set -T.
-T content-type
Content-type header for POST/PUT requests. e.g., 'application/x-www-form-urlencoded'
Default is 'text/plain'.
-v level
Verbosity level. 4 is most verbose.
-w
Print results in HTML tables.
-i
Use HEAD instead of GET.
-g filename
Output all results to gnuplot format file.
-e filename
Output CSV file with percentages served.
-h
Display usage information.
-k
Enable HTTP KeepAlive feature.
-H attribute
Add an arbitrary header line, e.g., 'Accept-Encoding: gzip'
Header lines are normally appended. If you supply a header line that begins with '_', it will be prepended, with the underscore(s) stripped.
-A attribute
Add Basic WWW Authentication, the attributes are a colon separated username and password.
-P attribute
Add Proxy Basic WWW Authentication, the attributes are a colon separated username and password.
-X proxy[:port]
Proxy server and port number.
-V
Show version number and exit.
-W
When doing a PUT or POST, do not send any data.
-d
Do not show percentiles served table.
-S
Do not show confidence estimators and warnings.
-q
Do not show progress counters.
-Z cipherstring
Specify SSL/TLS cipher suite (See openssl ciphers). If the OpenSSL version used to build ab is 1.0.2 or later, the argument can also be 'openssl cipher list' to show the OpenSSL cipher string list.
Note that this is not the same format as what is used in the Apache httpd SSL configuration.
-f protocol
Specify SSL/TLS protocol (SSL2, SSL3, TLS1, TLS1.1, TLS1.2, or ALL).
-4
Resolve hostname to IPv4 addresses.
-6
Resolve hostname to IPv6 addresses.
DESCRIPTION
ab is a command-line tool designed for benchmarking the performance of HTTP web servers. It's specifically tailored to gauge the capacity and responsiveness of web servers by simulating multiple concurrent requests and measuring the time taken to complete those requests. This utility helps identify bottlenecks, assess server stability under load, and determine the maximum requests per second (RPS) a server can handle. ab sends requests and measures the time that the HTTP server takes to respond, helping evaluate the server's capabilities. It's a valuable tool for developers, system administrators, and anyone concerned with optimizing web server performance.
CAVEATS
ab simulates client requests, which may not fully represent real-world user behavior. Network conditions and server configurations significantly impact the results. It is not suitable for testing complex application logic; more specialized benchmarking tools are better.
IMPORTANT METRICS
Key metrics include requests per second (RPS), time per request (mean, across all concurrent requests), transfer rate (bytes per second), and percentage of requests served within certain time brackets. These figures provide insights into server responsiveness and capacity.
INTERPRETING RESULTS
A high RPS indicates the server's ability to handle many requests quickly. Lower time per request shows efficient processing. Unexpected errors or timeouts suggest server overload or configuration issues. Always consider the context of the benchmark setup when interpreting results.
HISTORY
ab has been part of the Apache HTTP Server project since its inception. It has evolved along with the server, becoming a standard tool for performance testing. Its initial development focused on simple load generation and response time measurement. Over time, features like keep-alive, POST support, and SSL/TLS have been added.