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 Document Path: / Concurrency Level: 1 Connection Times (ms) Percentage of the requests served within a certain time (ms) |
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.