Overview
We use load testing to check how our application behavior when large number of requests concurrently access the application. This post is about how to do a simple load test with Apache Bench.
Install Apache Bench
Apache Bench(AB) is simple command line load testing tool for web servers. First install Apache bench with Apache utils.sudo apt-get install apache2-utils
For windows you can download XAMPP or WAMP and since Apache bench is independent file it will be in bin file as ab.exe.
in xampp,
.\xampp\apache\bin\ab.exe
by running ab.exe you can start Apache bench.
How to perform simple load test
You can do simple load test with your web server url .ab -n 10 -c 10 http://waruapz.blogspot.com
Here I have just enter my blog url. Change it with your application url.
Here ,
n = requests Number of requests to perform
c = concurrency Number of multiple requests to make
You can the output as follows.
Benchmarking waruapz.blogspot.com (be patient).....done
Server Software: GSE
Server Hostname: waruapz.blogspot.com
Server Port: 80
Document Path: /
Document Length: 87007 bytes
Concurrency Level: 10
Time taken for tests: 18.041 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 874030 bytes
HTML transferred: 870070 bytes
Requests per second: 0.55 [#/sec] (mean)
Time per request: 18041.184 [ms] (mean)
Time per request: 1804.118 [ms] (mean, across all concurrent requests)
Transfer rate: 47.31 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 51 76 18.5 79 105
Processing: 8412 13681 3090.4 14737 17990
Waiting: 459 1580 807.1 1566 2655
Total: 8491 13757 3096.1 14834 18041
Percentage of the requests served within a certain time (ms)
50% 14834
66% 15042
75% 16572
80% 16710
90% 18041
95% 18041
98% 18041
99% 18041
100% 18041 (longest request)
Here you can see some stats about testing like number of requests per secong ,maximum and minimum processing time etc.
Other Apache Bench parameters can be listed with ab command as below.
ab
ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-b windowsize Size of TCP send/receive buffer, in bytes
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header for POSTing, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL3, TLS1, or ALL)
Apache bench mark mainly use for simple projects. There are other tools like Jmeter, Soap-ui use vastly in industry.
Hello Waruna,
ReplyDeleteThe Article on Load testing with Apache Bench, gives detailed information about it. Thanks for Sharing the information about For More information check the detail on the load testing here Software Testing Services