ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.
- You can increase the total requests. It should always be more than number of concurrent requests.
- You can also add -H “Accept-Encoding: gzip,deflate” to more closely emulate real requests. But as we are on same server and there is no network overhead, it will not matter too much.
- For such high number of request the test should be done locally or on same LAN (Local Area Network). Otherwise you may get bad results due to network latency and you may think its your server problem. In reality all you concurrent users won’t come from one machine.
- This tests does not emulate the real environment fully. But it is good enough to help you find out most of the major problems in your site.
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-b windowsize Size of TCP send/receive buffer, in bytes
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header for POSTing, eg.
‘application/x-www-form-urlencoded’
Default is ‘text/plain’
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. ‘Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don’t exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
Example
[[email protected] ~]# ab -n 100 -c 20 -g http://gnutoolbox.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking gnutoolbox.com (be patient)…..done
Server Software: Apache
Server Hostname: gnutoolbox.com
Server Port: 80
Document Path: /
Document Length: 0 bytes
Concurrency Level: 20
Time taken for tests: 14.082 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Non-2xx responses: 100
Total transferred: 31300 bytes
HTML transferred: 0 bytes
Requests per second: 7.10 [#/sec] (mean)
Time per request: 2816.460 [ms] (mean)
Time per request: 140.823 [ms] (mean, across all concurrent requests)
Transfer rate: 2.17 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 359 377 15.2 374 426
Processing: 1329 2316 474.0 2195 3631
Waiting: 1329 2315 474.0 2193 3627
Total: 1734 2693 476.8 2580 4008
Percentage of the requests served within a certain time (ms)
50% 2580
66% 2779
75% 2962
80% 3029
90% 3420
95% 3719
98% 3900
99% 4008
100% 4008 (longest request)