Benchmarking and Load Testing with Apache Bench(AB)

From Brian Nelson Ramblings
Revision as of 18:52, 18 March 2014 by Brian (Talk | contribs) (Created page with "==Benchmarking and Load Testing with Apache Bench(AB)== ApacheBench (ab) is a very handy webserver benchmarking tool which can be run from command line. It is extremely simpl...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Benchmarking and Load Testing with Apache Bench(AB)

ApacheBench (ab) is a very handy webserver benchmarking tool which can be run from command line. It is extremely simple to use. A quick outcome can be obtained in just one minute. It does not require too much much familiarity with load and performance testing concepts. No complex setup is required. It gets installed automatically with apache. It does not have all the features of more popular tools, but it is good for a start.

Using AB Testing on Centos

One thing to not, you should never run ab on your localhost against your localhost.

Let run our first test,

ab -n 10000 -c 1000 http://www.briansnelson.com/Main_Page

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 www.briansnelson.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache
Server Hostname:        www.briansnelson.com
Server Port:            80

Document Path:          /Main_Page
Document Length:        30431 bytes

Concurrency Level:      1000
Time taken for tests:   67.478 seconds
Complete requests:      10000
Failed requests:        326
   (Connect: 0, Receive: 0, Length: 326, Exceptions: 0)
Write errors:           0
Total transferred:      298394530 bytes
HTML transferred:       294389494 bytes
Requests per second:    148.20 [#/sec] (mean)
Time per request:       6747.792 [ms] (mean)
Time per request:       6.748 [ms] (mean, across all concurrent requests)
Transfer rate:          4318.46 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        9  783 2342.6     14   15051
Processing:    30 2046 3418.0   1144   67429
Waiting:        0  354 801.7     23   14063
Total:         41 2829 4583.3   1624   67473

Percentage of the requests served within a certain time (ms)
  50%   1624
  66%   2455
  75%   3168
  80%   3599
  90%   5931
  95%   9875
  98%  17350
  99%  23289
 100%  67473 (longest request)

Lets break down the request we used with the ab command

  • -n is the total number of request to make
  • -c is the number of concurrent connections to make
  • and last is the domain name/url you wish to test on