Apache Bench Tool

25th February 2008

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.

  1. Benchmarking www.google.com (be patient).....done
  2.  
  3. Server Software: gws
  4. Server Hostname: www.google.com
  5. Server Port: 80
  6.  
  7. Document Path: /index.html
  8. Document Length: 231 bytes
  9.  
  10. Concurrency Level: 1
  11. Time taken for tests: 0.94090 seconds
  12. Complete requests: 1
  13. Failed requests: 0
  14. Write errors: 0
  15. Non-2xx responses: 1
  16. Total transferred: 590 bytes
  17. HTML transferred: 231 bytes
  18. Requests per second: 10.63 [#/sec] (mean)
  19. Time per request: 94.090 [ms] (mean)
  20. Time per request: 94.090 [ms] (mean, across all concurrent requests)
  21. Transfer rate: 0.00 [Kbytes/sec] received
  22.  
  23. Connection Times (ms)
  24. min mean[+/-sd] median max
  25. Connect: 41 41 0.0 41 41
  26. Processing: 52 52 0.0 52 52
  27. Waiting: 51 51 0.0 51 51
  28. 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.

  1. Benchmarking www.google.com (be patient).....done
  2.  
  3. Server Software: gws
  4. Server Hostname: www.google.com
  5. Server Port: 80
  6.  
  7. Document Path: /index.html
  8. Document Length: 231 bytes
  9.  
  10. Concurrency Level: 10
  11. Time taken for tests: 0.229686 seconds
  12. Complete requests: 10
  13. Failed requests: 0
  14. Write errors: 0
  15. Non-2xx responses: 10
  16. Total transferred: 5900 bytes
  17. HTML transferred: 2310 bytes
  18. Requests per second: 43.54 [#/sec] (mean)
  19. Time per request: 229.686 [ms] (mean)
  20. Time per request: 22.969 [ms] (mean, across all concurrent requests)
  21. Transfer rate: 21.77 [Kbytes/sec] received
  22.  
  23. Connection Times (ms)
  24. min mean[+/-sd] median max
  25. Connect: 41 55 9.1 55 68
  26. Processing: 54 100 37.9 87 164
  27. Waiting: 51 97 37.8 83 159
  28. Total: 95 155 43.9 149 229
  29.  
  30. Percentage of the requests served within a certain time (ms)
  31. 50% 149
  32. 66% 175
  33. 75% 189
  34. 80% 210
  35. 90% 229
  36. 95% 229
  37. 98% 229
  38. 99% 229
  39. 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

Permalink

Yeah, it's a pretty good article, althought it is in Russian...

Google translate seems to do the job though :)

Add new comment

The content of this field is kept private and will not be shown publicly.