Load Testing Using ab

ab - Apache HTTP server benchmarking tool

# which ab
/usr/bin/ab

# rpm -qf /usr/bin/ab
httpd-tools-2.2.15-39.el6.centos.x86_64
httpd-tools-2.2.15-47.el6.centos.x86_64


Flag Description
-n The number of requests to be performed (Default is 1)
-c The number of concurrent requests to be performed at a time (Default is 1)
-k Enabled the 'Keep Alive' feature to perform multiple requests in the same HTTP session (Default is NO Keep Alive)
-H Append extra headers to the request


Testing

ab -n 10000 -kc 10000  http://www.example.com/


Example Output

# ab -n 10000 -kc 100  http://www.example.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.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:        www.example.com
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      100
Time taken for tests:   626.200 seconds
Complete requests:      10000
Failed requests:        292
   (Connect: 0, Receive: 0, Length: 292, Exceptions: 0)
Write errors:           0
Non-2xx responses:      10000
Keep-Alive requests:    9979
Total transferred:      4572236 bytes
HTML transferred:       82078 bytes
Requests per second:    15.97 [#/sec] (mean)
Time per request:       6261.999 [ms] (mean)
Time per request:       62.620 [ms] (mean, across all concurrent requests)
Transfer rate:          7.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      45
Processing:     0 6228 1160.6   6409   13086
Waiting:        0 6228 1160.6   6408   13086
Total:          0 6228 1160.5   6409   13086

Percentage of the requests served within a certain time (ms)
  50%   6409
  66%   6509
  75%   6574
  80%   6616
  90%   6749
  95%   6879
  98%   7098
  99%   7252
 100%  13086 (longest request)


Common Issues

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.example.com (be patient)
socket: Too many open files (24)