X

Load testing Apache Web Server using ab

Apache Bench ( Popularly known as ab ) is used to test the performance of webserver running Apache , It is a famous light weight command line utility used to do load testing of a website and is useful in checking the scalability of your apache webserver.

Installing Apache Benchmark (ab)

To install ab in Ubuntu/Debian

# aptitude install apache2-utils

To install ab in CentOS

# yum install httpd-tools

 

Load testing using ab

Example 1 : Load testing  a website by sending number 1000 number of request to url http://www.abc.com

# ab -n 1000 http://www.abc.com/

(Note: remember to add trailing slash to url)

You will see output something like below

Benchmarking www.abc.com (be patient)
^C

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

Document Path:          /
Document Length:        226 bytes

Concurrency Level:      1
Time taken for tests:   21.769 seconds
Complete requests:      56
Failed requests:        0
Write errors:           0
Non-2xx responses:      56
Total transferred:      23968 bytes
HTML transferred:       12656 bytes
Requests per second:    2.57 [#/sec] (mean)
Time per request:       388.733 [ms] (mean)
Time per request:       388.733 [ms] (mean, across all concurrent requests)
Transfer rate:          1.08 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:      180  193   8.0    197     209
Processing:   182  195   8.4    198     213
Waiting:      182  195   8.4    198     213
Total:        362  388  16.3    395     420

Percentage of the requests served within a certain time (ms)
50%    395
66%    396
75%    398
80%    398
90%    411
95%    419
98%    419
99%    420
100%    420 (longest request)

It is very easy to deduce the output , isn’t it ?

In previous example the requests sent to the apache server are not concurrent and are consecutive in nature , What if we have to simulate multi user environment and want to send concurrent request ? Lets hop below

Example 2:  Load testing a website by sending number 1000 number of request to url http://www.abc.com in multiples of 5 (5 concurrent request)

# ab -n 1000 -c 5  http://www.abc.com/

Their are tons of option with ab command , which can be used with it you can –help option to discover more features.

 

 

 

  • Tags: ab, apache benchmark, load testing using ab,