This is an old revision of the document!


Apache Benchmarking

The Goal of Benchmarking

The goal of doing benchmark tests is to see what the practical configuration would be for Apache. Specifically, what settings to use primarily for MaxClients, which is maximum number of concurrent connections allowed. MaxRequestsPerChild could be changed as well.

Using ab

You can use ab to do simple benchmark tests, and even have them output to a CSV file.

An example, that uses 25 concurrent connections, runs tests until it does 1,500 requests, keep-alive is turned on, and outputs to a CSV file:

ab -c 25 -v -k -n 1500 -e /tmp/output.csv  http://localhost/

Howto Run a Benchmark Test

Before you do any tests suites, use CGP to determine that average number of webserver connections over a specific period of time (week, month, etc.). Then use that average as the number of concurrent connections, to simulate the benchmark under normal conditions.

Once you have the average number of connections, you can simulate the load under any length of time. Fifteen seconds (one quarter of a minute) is a good number that is both realistic in simulation as well as wait time for the tester.

Simulating the average number of connections (5) over 15 seconds.

ab -c 5 -t 15 -v -k http://localhost/

Please note that in benchmarking, timeout (-t 15) and number of requests (-n 65) are mutually exclusive. Pick one. :)

Running a test over a period of time is probably going to be easier to see, as you can watch the results in realtime with the system load. The opposite, using a number of requests, would be good if you wanted to simulate a sudden spike.

Sample Benchmark

Using an Apache installation on my desktop, here are some benchmark tests, using PHP and the prefork MPM, and the default Apache configuration.

Default Settings
  • Timeout 300
  • KeepAlive On
  • MaxKeepAliveRequests 100
  • KeepAliveTimeout 15
  • ServerTokens Prod
MPM Settings
  • StartServers 5
  • MinSpareServers 5
  • MaxSpareServer 10
  • MaxClients 150
  • MaxRequestsPerChild 10000
Results

Timeout value for all results are 15 seconds.

  • R/S = Requests per second [#/sec] (mean)
  • TPR = time per request
  • TPR (mean) = (mean)
  • TPR (all) = (mean, across all concurrent requests)
Concurrent R/S TPR (mean) TPR (all)
20 17.6 1136 56
40 29.19 1370 34
60 25.22 2378 40
80 28.45 2812 35
100 26.79 3732 37
120 23.86 5028 42
140 24.71 5665 40
160 23.15 6911 43
180 14.65 12283 68
200 10.59 18885 94