·

photo credit: Blackness Castle Siege 2012 via photopin (license)

Stress Test your site with Siege

When your developing your site on your local environment, it’s easy to get a feel of how fast and snappy it is. However, when your site goes public into the real world, problems can arise that you didn’t have before. These problems often are related to the performance of your site and the underlying course is peaks of simultaneous traffic to your site.
So how can we prepare ourselves for these kind of problems?

Stress testing

One test for your site that could show great insight in the performance of your site is the stress test. This test simulates a lot of concurrent requests to your site and measures the response time. There are many different tools for this test, but the one I want to describe here is Siege.

Siege

Siege is a nice little command line tool that does nothing more then mimic an X amount of concurrent users that try to access your site at once. It’s nice, tiny and very simple to use but also a very powerful tool to stress-test your site.

Installation

The easiest way to install Siege on OSX is by using Homebrew:

Usage

Siege is a command line-tool so the terminal is where you’ll spend most of your time. To generate a new global configuration file, type:

This will generate a file called .siegerc  in your home directory with the global configuration. You can check your global configuration by typing

This will output something similar to:

Most of these configuration items can be overwritten by redefining them on the command line. For example, to set a different amount of concurrent users, you can use the -u  flag. Or if you want to set a time for your test, you can use the -t  flag.

Examples

To stress-test a domain, simply type:

This will apply the default configuration and send 15 concurrent users for an infinite amount of time to the domain ‘www.domain.com’. Of course, when you’re stress-testing your own site, you need to use your own domain for this.
To change the amount of concurrent users to 100, you can type:

Or if you want to run the siege just for 60 seconds:

Another nice feature that you might want to use is the ability to use a file with URL’s and let Siege test them all. These URL’s must all be on separate lines:

If you make use of the -i option, Siege picks the URL’s randomly from this file so your stress-test behaves like a more real-world scenario:

In conclusion

It’s important to do these kind of tests. Even with tools like Varnish (when configured properly) it’s possible that your site will fail under a heavy simultaneous load. Using tools like Siege help you as a developer to simulate the situations that trigger this situation so you can fix it.
I want to thank my colleague Marco Bax for pointing me to this nice little tool. He also wrote an excellent post about this in Dutch.

Visitors give this article an average rating of 4.4 out of 5.

How would you rate this article?

One thought on “Stress Test your site with Siege”

  1. Max Uroda says:

    Thanks for the great post!

    I would like to note that you have errors in the following examples
    1) siege http://www.domain.com -f urls.txt
    2) siege http://www.domain.com -i -f urls.txt

    – it will run the test only for the URL “http://www.domain.com” , URL’s from “urls.txt” will be ignored.

Leave a Reply