Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Stress Testing Web Servers With Apache Benchmark

Sometimes it's worth knowing how well your web-server will cope with a large amount of demand. Especially if your expecting some large sale, or you want to see how much of an improvement your new load balancing system will make.

Related Posts And Tools

Apache Benchmark

Luckily enough for use there is already a tool called Apache Bench to do this for you. For example:

ab -n 1000 -c 20
  • -n 1000 specifies that a total of 1000 requests should be made.
  • -c 20 specifies that 20 requests should be made concurrently (simultaneously) at a time (this is perhaps the most important factor).

You can install with sudo apt-get install apache2-utils -y

Example Output

$ ab -n 1000 -c 20
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,

Benchmarking (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache/2.4.10
Server Hostname:
Server Port:            80

Document Path:          /conference/#watch-highlights
Document Length:        114412 bytes

Concurrency Level:      20
Time taken for tests:   120.945 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      114724000 bytes
HTML transferred:       114412000 bytes
Requests per second:    8.27 [#/sec] (mean)
Time per request:       2418.893 [ms] (mean)
Time per request:       120.945 [ms] (mean, across all concurrent requests)
Transfer rate:          926.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       16   18  31.6     17    1014
Processing:   915 2391 218.0   2380    3831
Waiting:      365  746 163.5    725    2167
Total:        931 2410 220.0   2397    3849

Percentage of the requests served within a certain time (ms)
  50%   2397
  66%   2425
  75%   2443
  80%   2459
  90%   2523
  95%   2661
  98%   2901
  99%   3238
 100%   3849 (longest request)

This just sends HTTP requests, so the server being tested does not need to be using Apache.

Other Tools

Unfortunately, the Apache benchmark will just hit the page you are requesting and stop there. It won't act like a user's browser, which will then go fetch all referenced content, such as JavaScript scripts, CSS, and images. In order to perform a more accurate test of how well your webserver will perform, be sure to check out Gatling and JMeter.

Last updated: 30th June 2021
First published: 16th August 2018