Testing servers with ApacheBench (ab)

There are times when you'd like to see how much load a web server can take, and there are a lot of complicated tools around to simulate traffic.

If you use Apache, then you already have a nice, simple benchmark tool called 'ab' built in. It's not the most detailed, but its a very easy way of getting a quick sense of how well your server is performing.

On the command line:

ab -kc10 -t5 http://google.com/

This will take 5 seconds and return you a lot of statistics, the 'Requests per second' may well be the figure you're looking for. Obviously replace Google with your own site, and remember the trailing slash.

Some quick explanations:

'k' means use Keepalive - if you have keepalive enabled on your server then this will simulate more realistic browser behaviour as your visitors would likely make multiple keepalive requests.

'c10' means use 10 concurrent connections - more realistic that one single connection.

't5' means do this for 5 seconds, feel free to vary these values - but start small and work up.

Finally - don't do this from the same server you're benchmarking, try to use another separate machine as you'll affect the results if your server is having to both send and serve the requests.