Load test your website using apache benchmark

Rahul Prasad
A Coder’s Laboratory
4 min readMar 31, 2012

What is load test and why is it necessary?

Load test is the process of putting load on system and testing its response, its a way to determine how your system reacts under heavy load. You need load test for a website to determine possible issues which you may face under heavy traffic environment. For example http response may fail in case of heavy traffic or response time will increase tremendously.

What is AB and how to get it?

AB stands for apache benchmark. You can install it under ubuntu using following command

sudo apt-get install apache2-utils

How to use AB?

Open terminal and input following command.

ab -n 100 -c 5 http://example.org/

Note: Don’t forget to append trailing slash, else it won’t work.

It follows this format:

ab -n [number of connections] -c [number of concurrent users] [webpage to load test]

It will generate following output:

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 example.org (be patient).....done
Server Software: Apache
Server Hostname: example.org
Server Port: 80
Document Path: /
Document Length: 85424 bytes
Concurrency Level: 3
Time taken for tests: 86.730 seconds
Complete requests: 100
Failed requests: 12
(Connect: 0, Receive: 0, Length: 12, Exceptions: 0)
Write errors: 0
Total transferred: 8571728 bytes
HTML transferred: 8516828 bytes
Requests per second: 1.15 [#/sec] (mean)
Time per request: 2601.912 [ms] (mean)
Time per request: 867.304 [ms] (mean, across all concurrent requests)
Transfer rate: 96.52 [Kbytes/sec] received
Connection Times (ms)
min mean [+/-sd] median max
Connect: 323 342 52.8 326 687
Processing:1847 2256 700.6 2086 6737
Waiting: 388 411 65.4 393 814
Total: 2171 2598 729.3 2415 7187
Percentage of the requests served within a certain time (ms)
50% 2415
66% 2421
75% 2471
80% 2504
90% 3207
95% 3769
98% 6528
99% 7187
100% 7187 (longest request)

Understanding output

Server Software: Apache
Server Hostname: example.org
Server Port: 80
First three lines says server which is being tested is apache server whose hostname is example.orgDocument Path: /
Document Length: 85424 bytes
Next two lines says, the page being tested is / (it will be /index.php if you will put url as http://example.org/index.php) and length of one page is 85424 bytes.Concurrency Level: 3AB is sending 3 concurrent request at a time. You should set it according to requirement. Its very rare that people will hit same page exactly same time. This only happens when your site is facing very heavy traffic all the time. Your website/webserver may behave very differently in case of too many concurrent connection for example race condition.Time taken for tests: 86.730 secondsThis is total time taken by AB.Complete requests: 100Number of request sent by AB.Failed requests: 12
(Connect: 0, Receive: 0, Length: 12, Exceptions: 0)
Number of request failed. As I mentioned earlier in case of heavy traffic or high concurrency a request may fail. This is the number of request failed. If it is too much you should start worrying.Write errors: 0
Total transferred: 8571728 bytes
This is total data (HTML and Header) transferred by AB during test.HTML transferred: 8516828 bytesThis is total HTML data transferred by AB during test.Requests per second: 1.15 [#/sec] (mean)This is a measur of your server's capacity. It says your server can withstand 1.15 request per second when it is facing this much of load.Time per request: 2601.912 [ms] (mean)
Time per request: 867.304 [ms] (mean, across all concurrent requests)
This is average of total time taken since a request is sent and a response is totally downloaded.Transfer rate: 96.52 [Kbytes/sec] received
Connection Times (ms)
min mean [+/-sd] median max
Connect: 323 342 52.8 326 687
Processing:1847 2256 700.6 2086 6737
Waiting: 388 411 65.4 393 814
Total: 2171 2598 729.3 2415 7187
Above lines means minimum time taken for a request to complete is 2171 ms, maximum time is 7187 sec, while average time is 2598 ms with standard deviation of 729 ms.Percentage of the requests served within a certain time (ms)
50% 2415
66% 2421
75% 2471
80% 2504
90% 3207
95% 3769
98% 6528
99% 7187
100% 7187 (longest request)
Above lines shows that more than 80% of the requests were served within 3 secs, but when number of open connections increased time taken to serve each request increased more than two times.

--

--