Siege with User Authentication

If you want to stress test your application, the quickest and best way to do so is with siege. From the siege website:

Siege is an http load testing and benchmarking utility. It was designed to let web developers measure 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 lets its user hit a web server with a configurable number of simulated web browsers. Those browsers place the server “under siege.”

On Linux, you can install it easily via yum or apt. On OS X, you can install it easily via homebrew or macports. I personally prefer homebrew. In your terminal just type:

brew install siege

Now you can stress test a given app by simply using the siege command:

siege -c 10 -n 10

You can read the documentation and faq on their site to learn more. However, there is one question I get a lot when talking about siege: “How can I use siege to test users who are logged in?”

I would always recommend that they send a session header in the config, but today I learned there is an even easier way (although undocumented), thanks to this question in Server Fault. In your siege’s configuration you can add the login-url directive:

# Login URL. This is the first URL to be hit by every siege
# client. This feature was designed to allow you to login to 
# a server and establish a session. It will only be hit once
# so if you need to hit this URL more then once, make sure it
# also appears in your urls.txt file.
# ex: login-url = POST name=jeff&pass=foo
# login-url = 

Awesome! Now each connection will authenticate before continuing their siege. A very handy tool, especially if your load is generated by user account pages and such.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close