Apache Performance Testing

Share this article

I have been starting to work with ab – included with Apache and not a new tool. ab allows for performance testing of web pages, sites and even dynamic scripts based on user load.

ab enables the creation of single or multiple requests per second and provides a nice results report.

Some of the key options, which can be viewed by running ‘man ab’ on any Linux or OS X installation with Apache installed.


-k: This enables HTTP KeepAlive so that multiple requests are carried out wihtin one session.

-n: Number of requests to perform, as in 150. They will be issued one after another until done.

-t: Issues a time limit on the time frame wihtin which the requests can be carried out.

-c: Allows for multiple requests simultaneously rather than one at a time. This can be good to test script performance.

-A username and password separated by a colon: This is used to send authentication if login is required on the site you are testing.

There are several other options including working through proxy servers, adding headers and cookies.

Results are output to the command line (example below from an OS X localhost Apache install):

This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done
Server Software: Apache/1.3.33
Server Hostname: localhost
Server Port: 80

Document Path: /
Document Length: 1456 bytes

Concurrency Level: 1
Time taken for tests: 1.103 seconds
Complete requests: 50
Failed requests: 0
Broken pipe errors: 0
Total transferred: 93500 bytes
HTML transferred: 72800 bytes
Requests per second: 45.33 [#/sec] (mean)
Time per request: 22.06 [ms] (mean)
Time per request: 22.06 [ms] (mean, across all concurrent requests)
Transfer rate: 84.77 [Kbytes/sec] received

Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 3
Processing: 12 21 60.0 12 438
Waiting: 12 21 59.8 12 436
Total: 12 21 60.4 12 441

Percentage of the requests served within a certain time (ms)
50% 12
66% 13
75% 13
80% 13
90% 14
95% 17
98% 441
99% 441
100% 441 (last request)

You can also output the results to a CSV file using a ‘-e filename’ option. ‘-w’ outputs the results to an HTML table. There is the ability to leverage ab from within PHP so as to generate load tests from a web browser and return results, though I have not attempted this as of yet. Primarily I have been running ab on development servers prior to a shift to production — and then running it again in the production environment prior to release.

Blane WarreneBlane Warrene
View Author
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form