Stress Testing Web Servers With Apache Benchmark
Sometimes it's worth knowing how well your web-server will cope with a large amount of demand. Especially if your expecting some large sale, or you want to see how much of an improvement your new load balancing system will make.
Luckily enough for use there is already a tool called Apache Bench to do this for you. For example:
ab -n 1000 -c 20 http://my-site.com
-n 1000specifies that a total of 1000 requests should be made.
-c 20specifies that 20 requests should be made concurrently (simultaneously) at a time (this is perhaps the most important factor).
$ ab -n 1000 -c 20 http://www.my-site.com//conference/#watch-highlights This is ApacheBench, Version 2.3 <$Revision: 1663405 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking www.my-site.com (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Apache/2.4.10 Server Hostname: www.my-site.com Server Port: 80 Document Path: /conference/#watch-highlights Document Length: 114412 bytes Concurrency Level: 20 Time taken for tests: 120.945 seconds Complete requests: 1000 Failed requests: 0 Non-2xx responses: 1000 Total transferred: 114724000 bytes HTML transferred: 114412000 bytes Requests per second: 8.27 [#/sec] (mean) Time per request: 2418.893 [ms] (mean) Time per request: 120.945 [ms] (mean, across all concurrent requests) Transfer rate: 926.33 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 16 18 31.6 17 1014 Processing: 915 2391 218.0 2380 3831 Waiting: 365 746 163.5 725 2167 Total: 931 2410 220.0 2397 3849 Percentage of the requests served within a certain time (ms) 50% 2397 66% 2425 75% 2443 80% 2459 90% 2523 95% 2661 98% 2901 99% 3238 100% 3849 (longest request)
First published: 16th August 2018