Tuesday 16 January 2007 1:33:00 pm
ApacheBench, or "ab", is a small tool bundled with the Apache webserver that is used to check the maximum performance of your webserver or web application. It can only benchmark one URL at a time and does not include images, CSS files or other items included on a webpage. It basically hammers the URL and records how much time the webserver spends on serving the pages.
Concurrency is specified by the parameter -c and number of requests is specified with -n.
Here is an ab example with eZ Publish running on one server. We fetch 20 requests with concurrency ranging from 1-4. As you will see from the table below, the server scales well with 4 concurrent requests. This is also the maximum performance delivered from this server.
The commands used are as follows:
ab -c 1 -n 20 http://olympia.ezcluster.ez.no/base/ ab -c 2 -n 20 http://olympia.ezcluster.ez.no/base/ ab -c 3 -n 20 http://olympia.ezcluster.ez.no/base/ ab -c 4 -n 20 http://olympia.ezcluster.ez.no/base/
Below is a very simple table that you could create from ab output in order to demonstrate the server's ability to deal with an increasing number of concurrent requests
Concurrent requests | ||||
---|---|---|---|---|
1 | 2 | 3 | 4 | |
Pages per second | 14.0 | 24.8 | 31.0 | 35.5 |
Relative performance | 100% | 177% | 221% | 254% |
In this case, the theoretical maximum number of pageviews for this server is about 3 million (35.5*60*60*24) per day.
Here is another sample command and ab's resulting output:
$ ab -c 5 -n 100 http://mycachedsite.example.com/ 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 db.no (be patient).....done Server Software: Apache/1.3.33 Server Hostname: db.no Server Port: 80 Document Path: / Document Length: 228 bytes Concurrency Level: 5 Time taken for tests: 1.424 seconds Complete requests: 100 Failed requests: 0 Broken pipe errors: 0 Non-2xx responses: 100 Total transferred: 42200 bytes HTML transferred: 22800 bytes Requests per second: 70.22 [#/sec] (mean) Time per request: 71.20 [ms] (mean) Time per request: 14.24 [ms] (mean, across all concurrent requests) Transfer rate: 29.63 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 13 31 5.5 31 44 Processing: 32 39 26.6 36 294 Waiting: 19 39 26.6 36 294 Total: 32 70 27.6 70 327 Percentage of the requests served within a certain time (ms) 50% 70 66% 71 75% 71 80% 72 90% 75 95% 83 98% 109 99% 327 100% 327 (last request)
Ab is not a tool you can use to generate a natural load on the server. In such a case, you should use a tool like siege (described later in this article).
You can also use ab -help to see a list of all parameters ab can take. You can for example have ab log into a website with htauthentication.