All HowTo's

How to Stress-Test a WebServer (Siege, Gatling and basic Maths)

It’s important to know how many people a website server can handle at a given time. Tools like Siege and Gatling are open-source tools that can help.

Stress testing tools such as Siege and Gatling make a given number of TCP connections to the target webserver. A typical web browser visiting any given website will open several TCP connections to the server to improve performance. Let’s say that number is 5 – it does vary though. So if you use Siege to stress-test your webserver and you ask for 10 concurrent connections, your really simulating 2 real people.

The real question is this. How many people can visit your website and have a pleasant experience. Start with stress testing your webserver in stages. First test a low number such as 10 connections. For example “siege -c5-d15 www.example.local”. The -d15 means to delay each stage by 15 seconds.

Keep the results handy. You may want to draw a graph later.

The results we are interested in is how long connections take to complete. This is the “Longest transaction” in Siege results. We first have to decide how long a real person would wait for a page to load. Lets say it’s 10 seconds. Moving on.

Run the tests over and over until the “Longest transaction” reaches about 10 seconds. Keep the increments consistent so any graphs that you make later will look consistent. The first test is 10, the next is 30 and then 50 and so on.

siege -c10-d15 www.example.local
siege -c30-d15 www.example.local
siege -c50-d15 www.example.local
siege -c70-d15 www.example.local
siege -c90-d15 www.example.local

A sample result is:

Transactions:		           4 hits
Availability:		      100.00 %
Elapsed time:		       12.83 secs
Data transferred:	        0.04 MB
Response time:		        2.42 secs
Transaction rate:	        0.31 trans/sec
Throughput:		        0.00 MB/sec
Concurrency:		        0.75
Successful transactions:           4
Failed transactions:	           0
Longest transaction:	        2.73
Shortest transaction:	        2.23

When you hit the point where the “Longest transaction” is about 10 seconds, we know that the number of “TCP connections” that you chose is the maximum that the server can handle. Divide that by 5 and you have the maximum number of real people visiting your site at any given time.

IMPORTANT: The number that you come up with will be low. Possibly 50 or 60 concurrent TCP connections. Equating to 10 or 12 real people. But keep in mind that this number reflects the number of people who can click at the same time (put crudely) and expect a nice experience. Most people visiting a website will not continuously click links. Rather they will wait a period of time, such as 20 seconds while they soak in the information. You have enough at this point to get the number of visitors that your webserver can handle.