.

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:

  1. -c
    1. Concurrent connections. How many connections at once. The more the harder it will be stressed.
  2. -n
    1. The number of connection attempts in total. The more, the longer it will run
  3. http://address/
    1. 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:

  1. -k
    1. Keepalive. This can be helpful if the connection drops out half way through a stress test.
  2. -r
    1. 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:

This is an example of running apachebench

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

Happy stressing!

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.