- Target machine – a machine which is being benchmarked
- Host machine – a machine from where benchmark is initiated
- We can use same machine as target and host machine.
- We can run benchmark from multiple “host machines”. In facts more is better.
Install apachebench (apache2-utils)
Following command will install apachebench (ab command). Run it on host machine from where test is conducted.
apt-get install apache2-utils
Run “htop” on target machine
Install htop if its not installed already.
apt-get install htop
Then simply run
htop in a dedicated window/terminal.
Following example will run apachebench on example.com:
ab -n 10000 -c 10000 http://example.com/
- n = number of total requests
- c = number of concurrency (yep, this is same concurrency c10k problem refers to)
Following is sample apachebench output:
This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking example.com (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: nginx Server Hostname: example.com Server Port: 80 Document Path: / Document Length: 109988 bytes Concurrency Level: 10000 Time taken for tests: 37.977 seconds Complete requests: 10000 Failed requests: 0 Write errors: 0 Total transferred: 1104220000 bytes HTML transferred: 1099880000 bytes Requests per second: 263.31 [#/sec] (mean) Time per request: 37977.351 [ms] (mean) Time per request: 3.798 [ms] (mean, across all concurrent requests) Transfer rate: 28394.29 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 159 336 92.2 349 481 Processing: 1645 29446 12975.7 36427 37459 Waiting: 155 1029 1972.4 554 8900 Total: 2125 29782 12938.1 36704 37890 Percentage of the requests served within a certain time (ms) 50% 36704 66% 37003 75% 37104 80% 37159 90% 37401 95% 37527 98% 37618 99% 37709 100% 37890 (longest request)
Out of all tools I have used apachebench is most unfriendly.
Failed Request Count
First, you can ignore length-related “Failed requests” count. HTTP headers can change response length for replies.
Percentage of the requests served within a certain time (ms)
If you are subjecting your server to unrealistic load, you should bother for 90% requests.