Web server capacity depends on the requested page, connection handling, and the number of clients competing for resources. ApacheBench (ab) benchmarks a web server by sending repeated requests to one URL and reporting throughput, failures, and response times.
A fixed workload makes before-and-after comparisons meaningful only when the URL, request settings, benchmark client, and network path stay the same. ab sends identical requests rather than simulating browser page loads or user journeys, so its results describe that endpoint under that workload.
Benchmark traffic can slow a site or trigger rate limits, even when requests only read a page. An approved staging endpoint is preferable to a busy production service, and a separate benchmark client avoids competing with the server for resources.
The benchmark client needs ab and curl installed, plus access to an existing web server. On Debian and Ubuntu, the apache2-utils package provides ab without requiring an Apache server on the client.
Related: How to show HTTP response headers with curl
Related: How to test Apache configuration
Steps to benchmark a web server with ApacheBench (ab):
- Check the HTTP status of the approved endpoint.
$ curl -I http://www.example.net/ HTTP/1.1 200 OK ##### snipped #####
The same approved URL belongs in every command; http://www.example.net/ is an example address. The URL must include a path, even if it is only the trailing slash. A redirect points to a different resource; the final destination URL belongs in the benchmark. Authentication errors, missing pages, and server errors need resolving before a load test.
- Run a small baseline against the endpoint.
$ ab -n 20 -c 2 http://www.example.net/ ##### snipped ##### Document Path: / Document Length: 10671 bytes Concurrency Level: 2 Time taken for tests: 0.002 seconds Complete requests: 20 Failed requests: 0 ##### snipped #####
-n 20 sends 20 requests in total; -c 2 allows two at a time. The requested count should complete with no failures or Non-2xx responses line. A tiny run checks that the endpoint responds under light load; its throughput is too sensitive to startup and timing to establish capacity.
- Save a benchmark report at the approved concurrency.
Redirection replaces any existing ab-baseline.txt before the benchmark starts. A different report filename preserves earlier measurements. Ten concurrent requests are an example workload, not a safe limit for every server. Higher concurrency can overwhelm the service or the client. If availability deteriorates, Ctrl+C stops the run; an interrupted report is not a completed benchmark.
$ ab -n 1000 -c 10 http://www.example.net/ > ab-baseline.txt Completed 100 requests ##### snipped ##### Completed 1000 requests Finished 1000 requests
The report goes to ab-baseline.txt in the current directory, while progress messages remain on the terminal. Without -k, each request uses a new connection; -k enables connection reuse when that matches the traffic being measured. Comparisons need the same connection setting.
- Inspect the saved report for completed requests, errors, throughput, and response-time percentiles.
$ cat ab-baseline.txt ##### snipped ##### Concurrency Level: 10 Time taken for tests: 0.077 seconds Complete requests: 1000 Failed requests: 0 ##### snipped ##### Requests per second: 12938.12 [#/sec] (mean) Time per request: 0.773 [ms] (mean) Time per request: 0.077 [ms] (mean, across all concurrent requests) ##### snipped ##### Percentage of the requests served within a certain time (ms) 50% 0 ##### snipped ##### 95% 1 ##### snipped ##### 99% 47 100% 48 (longest request)
The Complete requests count must match the requested total. Zero Failed requests alone does not prove HTTP success, because errors such as 404 can appear under Non-2xx responses instead. Changing response lengths can also produce failures; -l suppresses length checks only when those changes are expected.
Requests per second is completed requests divided by elapsed time. The first Time per request value multiplies elapsed time by concurrency before dividing by the request count; the second divides elapsed time by the request count without that multiplier. The percentile table describes individual request timings, including slow responses that an average can hide. Here, 95% finished within 1 ms, but the slowest took 48 ms. Millisecond rounding can display very fast requests as zero.
This run lasted less than a tenth of a second, so its numbers are not a sustained-capacity estimate. A larger request count can give a more representative duration once the load is approved. Repeated runs with unchanged settings reveal variation; a different report filename preserves each result for comparison after a server change. CPU, memory, or network saturation on the client can cap the measured throughput.