How to stress test websites with ApacheBench
Okay so you have a Microsoft IIS or Apache web server, you placed a website on it and want to know if it will “fall over” under load, well I have just the tool for that!
ApacheBench (aka AB) is a stress testing tool part of Apache, it is fully configurable tool to allow you to specify the amount of attempts on the web server and the amount of concurrent connections.
ApacheBench is part of the Apache installation so simply installing Apache2 will give you access to the tool.
To install Apache, run the following:
#apt-get install apache2
The tool requires three switches in order to work, they are the following:
- Concurrent connections. How many connections at once. The more the harder it will be stressed.
- The number of connection attempts in total. The more, the longer it will run
- The website address to stress test. If stressing the root of the address a trailing “/” is required after the address. e.g http://domain.com/
Depending on hardware, software and network/internet configurations, you might not be able to stress the website to the max and might end up with all types of errors when running “ab”.
I recommend looking at also using two other switches:
- Keepalive. This can be helpful if the connection drops out half way through a stress test.
- Don’t exit on socket receive error. This is probably the more important of the two additional switches and can resolve a lot of problems.
This tool can be used in two ways, for good or for bad. A denial of service can be run against a server to purposefully overload the connections to the point the server will reject any new connections.
An example of running Apachebench can be seen in the screenshot below:
Examples of running ApacheBench:
- ab -n 1000 -c 100 http://domain.com/
- ab -n 10000 -c 1000 -k -r http://domain.com/index.html
- ab -n 10000 -c 1000 -k -r http://domain.com/about.html
Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.