The Apache Bench tool can be found in the bin directory of any standard instillation of the Apache HTTP server. It can be used to test the response times of any web server you want and can be useful if you want to stress test a mission critical server before it goes live.
To use the tool open a command prompt (or terminal), navigate the Apache bin folder and find the program ab, this is the Apache Bench tool. The simplest form of running the tool is to use a single URL. However, you must enter a full file name or the tool will give you an invalid URL error.
ab http://www.google.com/index.html
This gives the following output.
Benchmarking www.google.com (be patient).....done
Server Software: gws
Server Hostname: www.google.com
Server Port: 80
Document Path: /index.html
Document Length: 231 bytes
Concurrency Level: 1
Time taken for tests: 0.94090 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Non-2xx responses: 1
Total transferred: 590 bytes
HTML transferred: 231 bytes
Requests per second: 10.63 [#/sec] (mean)
Time per request: 94.090 [ms] (mean)
Time per request: 94.090 [ms] (mean, across all concurrent requests)
Transfer rate: 0.00 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 41 41 0.0 41 41
Processing: 52 52 0.0 52 52
Waiting: 51 51 0.0 51 51
Total: 93 93 0.0 93 93
In this example, the tool has made a single request to the Google server. Apache Bench can be made to complete multiple, concurrent requests to the server with the addition of two flags. The first flag is -n, which is used to tell Apache Bench how many tests it should run, if the number 5 is used, the tool will repeat itself 5 times. The second flag is -c, which is used to tell Apache Bench how many concurrent connections should be made. The following example repeats the original test, but this time uses the -n and -c flags to run the tests 10 times, with 10 connections each time.
ab -n 10 -c 10 http://www.google.com/index.html
This produced the following output.
Benchmarking www.google.com (be patient).....done
Server Software: gws
Server Hostname: www.google.com
Server Port: 80
Document Path: /index.html
Document Length: 231 bytes
Concurrency Level: 10
Time taken for tests: 0.229686 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Non-2xx responses: 10
Total transferred: 5900 bytes
HTML transferred: 2310 bytes
Requests per second: 43.54 [#/sec] (mean)
Time per request: 229.686 [ms] (mean)
Time per request: 22.969 [ms] (mean, across all concurrent requests)
Transfer rate: 21.77 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 41 55 9.1 55 68
Processing: 54 100 37.9 87 164
Waiting: 51 97 37.8 83 159
Total: 95 155 43.9 149 229
Percentage of the requests served within a certain time (ms)
50% 149
66% 175
75% 189
80% 210
90% 229
95% 229
98% 229
99% 229
100% 229 (longest request)
When running the tool on your own server you will rarely see times like this. For example, when running the tool with the same parameters on a local server with a standard Wordpress install it longest request time was 4227.
To find out a list of the options available just type in the following.
ab -h
Comments
Good article about ApacheBench http://plutov.by/post/apache_bench_easy_tool
Yeah, it's a pretty good article, althought it is in Russian...
Google translate seems to do the job though :)