AB website benchtest

Here’s a bench test utility by Apache. It’s great for testing the server’s web hosting performance. Run it initially and then run it after your tweaks to see if there’s improvements. This tool comes by default in RHEL and CentOS.

1. Run this command to see if the Apache Benchmark is present

# whereis ab

You should see this output (or similar) if it exists (this is on a Cpanel server)

root@server [~]# whereis ab
ab: /usr/bin/ab /usr/share/man/man1/ab.1.gz

2. Here’s the code to bench test your website:

 ab -n 8000 -c 100 http://yourdomain.com/

This will make 100 concurrent connections requesting the webpage up to 8000 times. Adjust it as needed.

Don’t forget the slash after your dot com. It needs it.

Here’s a sample output:

root@server [~]# ab -n 8000 -c 100 http://yourdomain.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 yourdomain.com (be patient)
Completed 800 requests
Completed 1600 requests
Completed 2400 requests
Completed 3200 requests
Completed 4000 requests
Completed 4800 requests
Completed 5600 requests
Completed 6400 requests
Completed 7200 requests
Completed 8000 requests
Finished 8000 requests


Server Software:        nginx
Server Hostname:        servertest.com
Server Port:            80

Document Path:          /
Document Length:        31032 bytes

Concurrency Level:      100
Time taken for tests:   8.057 seconds
Complete requests:      8000
Failed requests:        0
Write errors:           0
Total transferred:      250760000 bytes
HTML transferred:       248256000 bytes
Requests per second:    992.89 [#/sec] (mean)
Time per request:       100.717 [ms] (mean)
Time per request:       1.007 [ms] (mean, across all concurrent requests)
Transfer rate:          30392.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      12
Processing:     8  100  25.0     94     238
Waiting:        8  100  25.0     94     238
Total:         13  100  24.9     94     239

Percentage of the requests served within a certain time (ms)
  50%     94
  66%     98
  75%    103
  80%    108
  90%    124
  95%    151
  98%    198
  99%    212
 100%    239 (longest request)
root@server [~]# 

3. Interpreting the output

Server Software: nginx
Server Hostname: servertest.com
Server Port: 80

This tells us the info about the server, hostname and port. This test was done on an Apache Server with Nginx in the front-end to handle static pages.

Document Path: /
Document Length: 31032 bytes

The document path in this example is the main root location of the website primarily the index file. The document length presented above is 31kb.

Concurrency Level: 100

The concurrency Level is the concurrent connections to the server.

Time taken for tests:   8.057 seconds

Total time taken by Apache Benchmark

Failed requests:        0

This is the failed request. You’ll want to minimize this (eliminate failed request if possible).

Write errors:           0
Total transferred:      250760000 bytes

This is total transferred by Server test (HTML and Header info)

HTML transferred:       248256000 bytes

This is total HTML transferred by Server test.

Requests per second:    992.89 [#/sec] (mean)

This is the total request per second the server is serving. This server can handle 992 request per second quite well with no Failures.

Time per request: 100.717 [ms] (mean)
Time per request: 1.007 [ms] (mean, across all concurrent requests)

This is the average time taken for the request to be received and a file to be downloaded.

Transfer rate:          30392.56 [Kbytes/sec] received

The transfer rate is at 30Mb per second for this request

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      12
Processing:     8  100  25.0     94     238
Waiting:        8  100  25.0     94     238
Total:         13  100  24.9     94     239

The results here show the minimum time for a request to complete is 13ms and the maximum time would be 239ms. The average hovers around 100ms to complete with a standard deviation around 24.9.

Percentage of the requests served within a certain time (ms)
  50%     94
  66%     98
  75%    103
  80%    108
  90%    124
  95%    151
  98%    198
  99%    212
 100%    239 (longest request)

This here shows the longest response time for this test is 239ms but on average it will take about 100ms to respond +- 24.9ms.

Once you have an understanding, make some tweaks to your Apache/Website settings and rerun the test. Compare the two to see if there’s any performance gain.

Again test at your own risk. You should only run high load test on servers that you own.

admin has written 38 articles