Apache Bench for load testing and performance benchmark
Apache Bench for Load Testing
AB( Apache Bench) is a command line utility to measure performance of any web server. It’s originally designed to test the Apache HTTP server. AB is free open source software and distributed under the terms of the Apache License.
It’s good practice to Benchmark performance of the any server before deployment. AB tool will shows you how many request per second your webserver can handle.
To measure performance of web server pass a certain number of concurrent request and some number of repetition and check AB result. I would recommend you start from small concurrent and repetition. Increase the number of concurrent request and repetition untill your result not fail or your webserver load reaches your defined limit.
Installation:
In Ubuntu:
Refresh the package database.
$ apt-get update
Install the apache2-utils package to get access to ApacheBench.
$ apt-get install apache2-utils
In Redhat or Centos:
Install httpd-tools to get AB tool.
$ yum install httpd-tools
Usages:
$ ab -n 10 -c 10 http://localhost/index.php
Parameter Description:
- -n 10: ab will send 10 number of requests to server localhost.
- -c 10 : 10 multiple requests to perform at a time. Default is one request at a time.
Output:
ab -n 10 -c 10 http://localhost/index.php This is ApacheBench, Version 2.3 <$Revision: 655654gt;
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking localhost (be patient).....done
Server Software: Apache
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 38879 bytes
Concurrency Level: 10
Time taken for tests: 6.401 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 392381 bytes
HTML transferred: 388790 bytes
Requests per second: 1.56 [#/sec] (mean)
Time per request: 6400.818 [ms] (mean)
Time per request: 640.082 [ms] (mean, across all concurrent requests)
Transfer rate: 59.86 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 365 366 0.7 366 367
Processing: 2214 3170 1171.5 3006 6020
Waiting: 1634 2424 775.4 2430 3924
Total: 2580 3537 1171.6 3371 6387Percentage of the requests served within a certain time (ms)
50% 3371
66% 3580
75% 3603
80% 4516
90% 6387
95% 6387
98% 6387
99% 6387
100% 6387 (longest request)