Benchmark Your Website Using ab (apachebench)

Apachebench Bench Marking – How Fast is my Webpage?

Before you deploy your website for the masses, you may want to performance tune it to make it run faster and serve more users.  A simple tool that you can use to begin benchmarking your website with is apachebench or “ab”.  To get ab, you simply need to have a machine with apache installed.  While you can run it from the same machine as your webpage, it can also be more realistic to run it from a separate machine.  Find a machine with apache installed on it and you should have ab installed on it also.

Benchmark, Tune, Benchmark Again

When I have bench marked with ab, I have always followed a simple pattern:

  • Run an ab test and save the results
  • Make one change in the Apache or database configuration
  • Restarted Apache or the database
  • Re-run the exact same ab test to see if the change improved or worsened performance

Apachebench Usage

I do most of my ab benchmarking with just 3 simple parameters:

ab -c <concurrent requests to make> -n <total number of requests to perform> http://url/

remember the / at the end of the URL.

Example:

$ ab -c 10 -n 100 http://mywebsiteurl.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking uptimemadeeasy.com (be patient)…..doneServer Software:        Apache/2.2.15
Server Hostname:        mywebsiteurl.com
Server Port:            80Document Path:          /
Document Length:        42221 bytesConcurrency Level:      10
Time taken for tests:   59.334801 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      4244300 bytes
HTML transferred:       4222100 bytes
Requests per second:    1.69 [#/sec] (mean)
Time per request:       5933.480 [ms] (mean)
Time per request:       593.348 [ms] (mean, across all concurrent requests)
Transfer rate:          69.84 [Kbytes/sec] receivedConnection Times (ms)
min  mean[+/-sd] median   max
Connect:       31   31   0.9     32      33
Processing:  5525 5887  78.3   5901    6028
Waiting:     1721 2013  55.0   2026    2090
Total:       5557 5919  78.4   5933    6059
WARNING: The median and mean for the initial connection time are not within a normal deviation
These results are probably not that reliable.Percentage of the requests served within a certain time (ms)
50%   5933
66%   5950
75%   5962
80%   5975
90%   6014
95%   6022
98%   6025
99%   6059
100%   6059 (longest request)

Ab Can Help Improve Website Performance

Using the method explained above with ab, I have been able to significantly improve the performance of my webpages.  Specifically, I look at the “Percentage of Requests Served Within a Certain Time” section to watch for better numbers after the configuration changes.  Now you can benchmark your website using ab.

The following two tabs change content below.
Jeff has 20 years of professional IT experience, having done nearly everything in his roles of IT consultant, Systems Integrator, Systems Engineer, CNOC Engineer, Systems Administrator, Network Systems Administrator, and IT Director. If there is one thing he knows for sure, it is that there is always a simple answer to every IT problem and that downtime begins with complexity. Seasoned IT professional by day, Jeff hopes to help other IT professionals by blogging about his experiences at night on his blog: http://uptimemadeeasy.com. You can find Jeff on or LinkedIn at: LinkedIn or Twitter at: Twitter

Latest posts by Jeff Staten (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *