Programming - - By Paul Annesley

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
Sponsors