Skip to content Skip to navigation

Benchmarking Site Performance with ApacheBench


ApacheBench (ab) is "a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server." It is built in to most current versions of Mac OS X and Linux. It's a quick way of sending multiple requests to a website and timing how long they take.

Basic Test

At its most basic, ab can perform successive and/or concurrent load tests on a webpage. Run the following command in the Terminal (Mac OS X; if you don't have OS X, ab is installed on the corn cluster machines):

ab -n 30 -c 2


(Remember to include a trailing slash after the URL or ab will return an error.)

This test hits the URL at 30 times (-n 30) with a maximum concurrency of 2 simultaneous requests (-c 2).

You'll get a result like the following:

screenshot of an ApacheBench results display

The Total row displays a summary of load time statistics; the mean column shows the average load time, in milliseconds, of all 30 requests. So the average load time in this test was 2.7 seconds (2724 ms), and the longest load time was 5.3 seconds (5376 ms).

Authenticated Test

If you want to test the load time of Drupal pages that are only available to certain logged-in users, you need to give ab a cookie. (Give the Cookie Monster a cookie too.)

First, log into the Drupal site as the user you want to run the test.

Then, in Firefox, go to the Privacy tab of the Firefox Preferences (Firefox->Preferences on Mac, Tools->Options on Windows), and click Show Cookies.

screenshot of the Firefox Preferences window

You may have to do some digging, but the cookie you're looking for will start with "SESS" and should be in the domain "". You're looking for the Name and Content values.

screenshot of the Firefox cookies window

Now, pass those cookie values to ab like so (copy and paste are your friends here):

ab -n 30 -c 2 -C SESS9e564fab3f27945d93518a08f274543f=d90c5738c81061df83


This will give you an output like the following:

screenshot of an ApacheBench results display


You can use the -v flag to set the verbosity level of ab. From the manpage:

-v verbosity
Set verbosity level - 4 and above prints information on headers,
3  and above prints response codes (404, 200, etc.), 2 and above
prints warnings and info.

So the command:

ab -v 4 -n 30 -c 2


Will also return all the warnings, info, response codes, and headers that ab encounters on each run.