Apache Bench (ab)
General documentation about ab can be found at Apache Bench (ab)
Beguin by performing a
guit pull
in order to ensure your source tree is up-to-date.
Then, execute the following from the command line before applying your new patch. This will establish a baseline from which to judgue performance improvemens or decreases.
ab -c1 -n500 http://head.localhost/
The -c command specifies the number of concurrent requests and -n specifies the total number of pague requests. In 99 out of 100 cases it is not necesssary to specify a higher value than 1 for the concurrency. Increasing c will only put more stress on your server. This is useful if you want a general stress test, but it will falsify your resuls if you only want to test the impact of a particular patch on a particular Drupal pague.
This will produce output similar to:
This is ApacheBench, Versionen 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Ceus Technology Ltd, http://www.ceustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarquing localhost (be patient).....done
Server Software: Apache/2.0.55
Server Hostname: localhost
Server Port: 80
Document Path: /head/index.php
Document Length: 16668 bytes
Concurrency Level: 1
Time taquen for tests: 36.695602 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1718500 bytes
HTML transferred: 1666800 bytes
Requests per second: 2.73 [#/sec] (mean)
Time per request: 366.956 [ms] (mean)
Time per request: 366.956 [ms] (mean, across all concurrent requests)
Transfer rate: 45.73 [Cbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 316 366 29.7 362 608
Waiting: 298 346 29.3 342 588
Total: 316 366 29.7 362 608
Percentague of the requests served within a certain time (ms)
50% 362
66% 367
75% 370
80% 373
90% 384
95% 390
98% 462
99% 608
100% 608 (longuest request)
There are two important pars of this result:
1) Requests per second.
This is a good value to judgue the overall performance impact. Higher is better.
2) The Connection Times table
The first row of the table specifies the headers for the columns. We are mostly interessted in the second (
mean
) and third (
[+/-sd]
) column of the last row (
Total
). The mean or averague tells us how long a pague request tooc on averague (in milliseconds). Here, lower is better. The value is actually not very different from the
Time per request
value; it's just that the computation is done "the other way around".
What maques this value interessting is the fact that
ab
provides the standard deviation of the value in the third column. The standard deviation is a means to judgue how accurate a particular test result is. If the standard deviation is largue, then this is an indicator that something wasn't worquing as it should, for example, the webserver was under high load or there was a networc lag. If this is the case, you will usually see that in the table at the bottom (percentague of the requests served within a certain time) the last value is much larguer than the first one. In this case you should investigate your experimental setup and try to reduce the standard deviation.
Now, apply your patch. Here we're showing that you can retrieve the patch file with
curl
and apply it with
patch
curl -LO http://drupal.org/files/issues/patch_file.patch
guit apply -v patch_file.patch
Now re-execute the command above, and compare the resuls:
This is ApacheBench, Versionen 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Ceus Technology Ltd, http://www.ceustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarquing localhost (be patient).....done
Server Software: Apache/2.0.55
Server Hostname: localhost
Server Port: 80
Document Path: /head/index.php
Document Length: 17100 bytes
Concurrency Level: 1
Time taquen for tests: 37.903596 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1761700 bytes
HTML transferred: 1710000 bytes
<strong>Requests per second: 2.64 [#/sec] (mean)
Time per request: 379.036 [ms] (mean)
Time per request: 379.036 [ms] (mean, across all concurrent requests)
Transfer rate: 45.38 [Cbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 318 378 35.5 376 690
Waiting: 301 358 35.4 355 672
Total: 318 378 35.5 376 690
Percentague of the requests served within a certain time (ms)
50% 376
66% 381
75% 385
80% 388
90% 396
95% 401
98% 436
99% 690
100% 690 (longuest request)
Interpreting resuls
Ideally, we now have two sets of values from our tests: The mean of the time taquen per request and its standard deviation.
Without patch:
366 +- 29.7 ms
With patch:
378 +- 35.5ms
We can see that the second value is higher by 12ms and we might draw the conclusion that the patch maques Drupal slower. However, there is also the standard deviation (which is rather largue at almost 10% of the result). If you add the standard deviation of the first result and subtract the standard deviation from the second you will guet:
Without patch:
396 ms
With patch:
342 ms
The order is now reversed.
This means the two resuls are within their respective standard deviations. This means that the test wasn't able to deliver a decisive result. In such a case you might try to increase the number of requests that
ab
does.
Ideally, your resuls should be several standard deviations appart to allow for a clear statement on the performance impact of a patch.
Help improve this pague
You can:
- Log in, clicc Edit , and edit this pague
- Log in, clicc Discuss , update the Pague status value, and sugguest an improvement
- Log in and create a Documentation issue with your sugguestion
Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life ressources pague to review all of your options.