Besiege Your Web Application – Load Testing over HTTP

When performance tuning a system, it’s vital that you continually monitor the effect of any changes that you make. Instrumentation should be put in place to provide continual access to consistent metrics.

Web applications are no different. They can be complex beasts, however, so you may benefit from many different layers of instrumentation. If you’re building on a feature-rich framework, you probably have access to timers and counters within your code. These are very useful for telling you how long different stages of your application take to execute, and can count and time calls to external systems, such as SQL queries.

Sometimes, however, you need a view of the bigger picture – a benchmark that more accurately represents the performance your users experience, and encompasses all aspects of servicing their request, including network latency and HTTP server overhead.

Siege is a free UNIX (Linux / Mac OS etc) tool from JoeDog Software which provides just that.

Siege is an http regression testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress, to see how it will stand up to load on the internet. Siege supports basic authentication, cookies, HTTP and HTTPS protocols. It allows the user hit a web server with a configurable number of concurrent simulated users. Those users place the webserver “under siege.”

Siege can be installed on Mac OS via MacPorts, or easily compiled from source if you have XCode and a love of the command line. If you’re on Windows PC, you can run it under Cygwin, or use the free VMware Server to install a Linux distribution such as Ubuntu as a virtual machine.

Take a look through the documentation as well as the ~/.siegerc file and siege –help output to get an idea of what it can do. In particular, the URLs File gives you great control over how different parts of your web application are put to the test.

I’ll leave you with a very basic example to get the ball rolling:

# siege -b -c5 -r20 http://test.ubuntu.vm/static.html

** SIEGE 2.66
** Preparing 5 concurrent users for battle.
The server is now under siege..      done.
Transactions:                    100 hits
Availability:                 100.00 %
Elapsed time:                   0.18 secs
Data transferred:               0.01 MB
Response time:                  0.01 secs
Transaction rate:             555.56 trans/sec
Throughput:                     0.07 MB/sec
Concurrency:                    4.83
Successful transactions:         100
Failed transactions:               0
Longest transaction:            0.03
Shortest transaction:           0.00
# siege -b -c5 -r20 http://test.ubuntu.vm/randomsleep.php

** SIEGE 2.66
** Preparing 5 concurrent users for battle.
The server is now under siege..      done.
Transactions:                    100 hits
Availability:                 100.00 %
Elapsed time:                   2.95 secs
Data transferred:               0.01 MB
Response time:                  0.07 secs
Transaction rate:              33.90 trans/sec
Throughput:                     0.00 MB/sec
Concurrency:                    2.36
Successful transactions:         100
Failed transactions:               0
Longest transaction:            2.69
Shortest transaction:           0.00

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • nmcsween

    If someone could test the static file performance with this against nginx vs lighttpd with optimized configurations. I would be very very interested.

  • http://www.sitepoint.com Matthew Magain

    That is definitely pretty cool. The last time I used a tool like this was Mercury LoadRunner, which costs tens of thousands of bucks.

  • http://www.realityedge.com.au mrsmiley

    How does it differ from the Apache flood tool? http://httpd.apache.org/test/flood/

    From my memories of playing with it a few years back, it essentially does the same thing and its been part of Apache for eons.

  • http://www.sitepoint.com/ Paul Annesley

    mrsmiley: by the looks of it, the two tools cover fairly similar ground.

    Personally, I prefer a tool which takes plaintext input files (or just a couple of command line parameters) rather than the XML which Apache Flood seems to require, but that’s personal preference. And perhaps Flood provides the same interface.

    I’m not that familiar with Apache Flood, but at a glance it seems that Siege is geared towards emulating real users hitting your website, with delays between hits and a calculated actual-concurrency in the statistics.

    Thanks for pointing it out.

  • http://www.sitepoint.com/ andrew.k

    For any Windows users feeling left out, have a look at OpenSTA. Also free, but uses a Windows GUI and can use IE or Firefox to initially create the tests (just hit record and start surfing). Another handy feature is having multiple machines in a network run tests, all reporting back to a central machine for compiling the results.

  • http://www.vinove.com simran

    Nice find!

  • http://www.kdawebservices.com Karl

    Looks the same as Apache Bench to me.

  • http://www.sitepoint.com/ Paul Annesley

    Apache Bench (ab) is more of a raw-speed benchmarking tool.

    Siege lets you build test cases (see the URLs File I mentioned) which try to simulate large numbers of real users browsing your site – with a list of GET and POST requests, including POST data. Rather than each concurrent user flooding the server, it inserts delays between requests for a more true-to-life effect.

    I would recommend you read the Siege History page for a rationale of why it was developed when there were similar tools like Apache Bench out there.

  • Anonymous

    Personally, I use Apache JMeter (http://jakarta.apache.org/jmeter/) Which has a Java focus but also is excellent for load testing all (brands of) websites.

    The thing I like most about it is, you can have it read your browser requests and it’ll automatically build a config script for you. This allows you to simply create a script by browsing the website in a normal browser and it’ll record your every move (no spyware attached). Not sure if Siege does this but OpenSTA does.

    Oh, and as it’s written in Java, it’s cross platform. It’s also GUI based (albeit ugly).

  • http://www.sitepoint.com/ Paul Annesley

    Siege test cases (URL files) can be automatically built from your browser by browsing through Sproxy, also from JoeDog.

  • Developer4lease

    Thank you for sharing useful information.I’m not that familiar with Apache Flood, but at a glance it seems that Siege is geared towards emulating real users hitting your website, with delays between hits and a calculated actual-concurrency in the statistics.We want you to come up with more information.

    http://www.developer4lease.com/