InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Apache tutorials

  • AWStats on Ubuntu
  • ApacheBench - load testing
  • Auth to a location or directory
  • Block directory access using htaccess 404
  • Different expire Headers for multiple images
  • Disable directory listing
  • List loaded modules
  • Log Content-Type in access log
  • Log latency and host in apache log
  • Monitoring using mod_status
  • Python to analyze bots in logs
  • Remove php extension from url
  • egrep and access log
  • log custom data in apache access log
  • mod_rewrite
  • top IP list from access log
 
  • Home
  • > Tutorials
  • > Web Development
  • > Apache

ApacheBench (ab) – how to load test a web site

By admin | Last updated on Jan 13, 2016

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.

Environment for the test

Here is the setup I used:

  1. OS: Ubuntu server 12.04.1 LTS (LTS stands for Long term support)
  2. AWS details: Micro instance in california
  3. Site software: WordPress 3.5.1 with w3 total cache installed (using page cache in memcache)
  4. Web server: Apache 2.2.2 (prefork)

Running ApacheBench locally on web server machine

Run it on same server as your webserver using this command:

ab -n 500 -c 100 http://yoursite.com/

This will run it for 500 requests in total with 100 current requests. Here are some points to note:

  1. You can increase the total requests. It should always be more than number of concurrent requests.
  2. 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.
  3. 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.
  4. 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.

Testing outcome from ApacheBench

Here is the outcome for above command on my server:

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 infoheap.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        Apache/2.2.22
Server Hostname:        infoheap.com
Server Port:            80

Document Path:          /
Document Length:        24359 bytes

Concurrency Level:      100
Time taken for tests:   8.978 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      12305000 bytes
HTML transferred:       12179500 bytes
Requests per second:    55.69 [#/sec] (mean)
Time per request:       1795.684 [ms] (mean)
Time per request:       17.957 [ms] (mean, across all concurrent requests)
Transfer rate:          1338.39 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        2   18 117.2      3    1001
Processing:    92 1639 475.4   1771    3022
Waiting:       65 1583 455.4   1711    2930
Total:         96 1657 490.0   1780    3025

Percentage of the requests served within a certain time (ms)
  50%   1780
  66%   1866
  75%   1895
  80%   1915
  90%   1973
  95%   2421
  98%   2622
  99%   2654
 100%   3025 (longest request)

Analysis of the ApacheBench load testing output

Here are my observation about the outcome

  1. Total data transferred is 12305000 bytes for 500 requests. Close to 20K per page (un-compressed). Which is inline with my home page size.
  2. Test completed in 8.978. No failed requests. Very good number I think.
  3. Requests per seconds: 55.69. Pretty good number.
  4. Time per request: 1795.684 milli-seconds (for 100 concurrent requests). So across all requests it is 1795.684ms/100 = 17.957ms
  5. Transfer rate: 1338.39 [Kbytes/sec] received. Since we ran the test on same machine, this number was expected to be high and can be ignored.
  6. In connection time stats, you can see many requests had to wait for few seconds. This may be due to apache putting requests in wait queue.

Overall test results are good. This test does not really tested the network latency. But it primarily tested if 100 concurrent requests reached to the web server, how does it perform.

Plotting the outcome of ApacheBench

I generated the graph data for plotting using this command:

ab -n 500 -c 100 -g out.data http://yoursite.com/

And then plotted it using gnuplot. Here is the outcome.

ab-benchmarking-outcome-plot-infoheap

Suggested posts:

  1. How to redirect wordpress feed to feedburner feed url
  2. How to remove password from pdf using Chrome
  3. Mac – how to change desktop icons size
  4. Bash – how to find last command exit status code
  5. Linux du – find disk usage of directories or files
  6. PHP sort associative array using custom compare function
  7. document querySelector examples
  8. How to setup ssl (https) for your site on Ubuntu Linux
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Apache, Cloud, Linux, Load testing, Memcache, Site Performance, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress