background

Ab small pressure tool, for simple debugging in Linux or more convenient, lightweight and flexible.

The installation

  1. yum -y install httpd-tools

Check the version

  1. [root@7dgroup2 ~]# ab -V
  2. This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5.  
  6. help
  7. [root@7dgroup2 ~]# ab help
  8. ab: invalid URL
  9. Usage: ab [options] [http[s]://]hostname[:port]/path
  10. Options are:
  11. -n requests Number of requests to perform
  12. -c concurrency Number of multiple requests to make at a time
  13. -t timelimit Seconds to max. to spend on benchmarking
  14. This implies -n 50000
  15. -s timeout Seconds to max. wait for each response
  16. Default is 30 seconds
  17. -b windowsize Size of TCP send/receive buffer, in bytes
  18. -B address Address to bind to when making outgoing connections
  19. -p postfile File containing data to POST. Remember also to set -T
  20. -u putfile File containing data to PUT. Remember also to set -T
  21. -T content-type Content-type header to use for POST/PUT data, eg.
  22. 'application/x-www-form-urlencoded'
  23. Default is 'text/plain'
  24. -v verbosity How much troubleshooting info to print
  25. -w Print out results in HTML tables
  26. -i Use HEAD instead of GET
  27. -x attributes String to insert as table attributes
  28. -y attributes String to insert as tr attributes
  29. -z attributes String to insert as td or th attributes
  30. -C attribute Add cookie, eg. 'Apache=1234'. (repeatable)
  31. -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
  32. Inserted after all normal header lines. (repeatable)
  33. -A attribute Add Basic WWW Authentication, the attributes
  34. are a colon separated username and password.
  35. -P attribute Add Basic Proxy Authentication, the attributes
  36. are a colon separated username and password.
  37. -X proxy:port Proxyserver and port number to use
  38. -V Print version number and exit
  39. -k Use HTTP KeepAlive feature
  40. -d Do not show percentiles served table.
  41. -S Do not show confidence estimators and warnings.
  42. -q Do not show progress when doing more than 150 requests
  43. -g filename Output collected data to gnuplot format file.
  44. -e filename Output CSV file with percentages served
  45. -r Don't exit on socket receive errors.
  46. -h Display usage information (this message)
  47. -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
  48. -f protocol Specify SSL/TLS protocol
  49. (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)
  50. [root@7dgroup2 ~]#
  • -n Indicates the number of requests executed in the test session. By default, only one request is executed.
  • -c Indicates the number of requests generated at a time. The default is one at a time.
  • -t Indicates the maximum number of seconds for the test. Its internal implied value is -n 50000, which limits the testing of the server to a fixed total time. By default, there is no time limit.

Quick learning

  1. / root @ 7 dgroup2 ~ # ab - n10 - c 10 http://172.17.211.142:8089/
  2. This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5.  
  6. Very 172.17.211.142 (be patient)... done
  7.  
  8.  
  9. # Server Software
  10. Server Hostname: 172.17.211.142
  11. Server Port: 8089
  12.  
  13. Document Path: / # File Path
  14. Document Length: 76443 bytes # Number of bytes on the page
  15.  
  16. Concurrency Level: 10 # Number of concurrent requests
  17. Time taken for tests: 0.064 seconds #
  18. # Number of successful requests
  19. Failed requests: 0 # Number of Failed requests
  20. Write errors: 0
  21. Total extension: 766030 bytes # Requested Total extension size (including header header information)
  22. HTML transferred: 764430 bytes # Actual total bytes of HTML page
  23. Requests per second: 157.09 [#/ SEC] (mean) # Requests per second
  24. Time per Request: 63.656 [ms] (mean) #
  25. Time per request: 6.366 [ms] (mean, across all Concurrent requests) #
  26. Transfer Rate: 11751.86 [Kbytes/ SEC] Received # Length of data received per second
  27.  
  28. Connection Times (ms)
  29. min mean[+/-sd] median max
  30. Connect: 0 0 0.0 0 0
  31. Processing: 8 36 17.1 41 60
  32. Waiting: 3 24 18.7 18 55 # Waiting
  33. Total: 9 37 17.1 42 60
  34. #Total does not add the first three rows, because the first three rows were not collected in the same request,
  35. A request may have the shortest network latency, but the longest system processing time.
  36. # So Total is measured in terms of the time required for the entire request.
  37. Percentage of the requests served within a certain time (ms)
  38. 50% of the 42
  39. 66% of 45
  40. 75% of 51
  41. 80% of 52
  42. 90% of 60
  43. 95% of 60
  44. 98% of 60
  45. 99% of 60
  46. 100% 60 (longest request)