Looking through my server commands, there was a command called ‘ab’ that caught my eye. The command stands for ‘Apache Benchmark’ and it is a benchmarking tool for your webserver. Having never run a bench mark on my server I thought that this was a perfect opportunity to do so.

The command is designed to simulate a bunch of requests to your webserver from whatever machine you’re running the test from.

Syntax

ab [options] [http[s]://]hostname[:port]/path

Looking at the man page will give you the available options. you will need to use the ‘-n’ and ‘-c’ options. The ‘-n’ option indicates the number of requests to make, and the ‘-c’ options indicates how many of the connections should be concurrent. It states that it uses 1 as the default for concurrency, but when I kept getting errors when I left that option off. The command issued to benchmark my server was:

ab -n 1000 -c 5 http://www.8bitpipe.com/

The command give  you nice little updates after every 100 attempts. At the end of the test it will display a report giving you a range of times that the requests fall within. It is worth noting that you should be aware of the type of connection you have to the internet, any latency on your localnet will affect the test. As you may remember, I have a horrible connection to the internet and running the test from my local machine produced terrible results:

[root@localhost]# ab -n 1000 -c 5 http://www.8bitpipe.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.8bitpipe.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
Server Hostname:        www.8bitpipe.com
Server Port:            80

Document Path:          /
Document Length:        42100 bytes

Concurrency Level:      5
Time taken for tests:   3819.611 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      42279000 bytes
HTML transferred:       42100000 bytes
Requests per second:    0.26 [#/sec] (mean)
Time per request:       19098.054 [ms] (mean)
Time per request:       3819.611 [ms] (mean, across all concurrent requests)
Transfer rate:          10.81 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        2    8   5.2      7      51
Processing:  1690 19068 12676.4  15300  128973
Waiting:     1640 15453 5923.0  15252   24723
Total:       1694 19076 12676.3  15308  128977

Percentage of the requests served within a certain time (ms)
50%  15308
66%  19737
75%  25082
80%  25726
90%  34978
95%  42059
98%  49926
99%  65594
100%  128977 (longest request)

Compare this to a remote server that has a better connection:

[root@remotehost]# ab -n 1000 -c 5 http://www.8bitpipe.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.8bitpipe.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
Finished 1000 requests

Server Software:        Apache
Server Hostname:        www.8bitpipe.com
Server Port:            80

Document Path:          /
Document Length:        42100 bytes

Concurrency Level:      5
Time taken for tests:   39.341961 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      42279000 bytes
HTML transferred:       42100000 bytes
Requests per second:    25.42 [#/sec] (mean)
Time per request:       196.710 [ms] (mean)
Time per request:       39.342 [ms] (mean, across all concurrent requests)
Transfer rate:          1049.46 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   1.7      0      20
Processing:   129  195  38.1    189     495
Waiting:       58   89  22.9     85     295
Total:        129  195  38.1    189     495

Percentage of the requests served within a certain time (ms)
50%    189
66%    204
75%    216
80%    225
90%    247
95%    265
98%    285
99%    303
100%    495 (longest request)

That is much better. Don’t forget to run this on a regular basis to get the trends of your server response. Hopefully this will help keep your little portion of the internet more responsive.

Further Reading:

Howto Performance Benchmark a Web Server

Howto Benchmark

Leave a Reply