Benchmarking and Load Testing with Apache Bench(AB)

From Brian Nelson Ramblings
Revision as of 18:53, 18 March 2014 by Brian (Talk | contribs) (Using AB Testing on Centos)

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 100 -c 10 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).....done
 
Server Software:        Apache
Server Hostname:        www.briansnelson.com
Server Port:            80 

Document Path:          /Main_Page
Document Length:        30431 bytes 

Concurrency Level:      10
Time taken for tests:   0.433 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      3084500 bytes
HTML transferred:       3043100 bytes
Requests per second:    231.15 [#/sec] (mean)
Time per request:       43.262 [ms] (mean)
Time per request:       4.326 [ms] (mean, across all concurrent requests)
Transfer rate:          6962.71 [Kbytes/sec] received 

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        9    9   0.4      9      11
Processing:    28   32   2.7     31      53
Waiting:        9   10   1.3     10      16
Total:         39   41   2.8     40      61

Percentage of the requests served within a certain time (ms)

 50%     40
 66%     41
 75%     41
 80%     42
 90%     44
 95%     46
 98%     49
 99%     61
100%     61 (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