Load testing
For load testing we recommend two different tools:
-
Siege for testing straightforward read operations. Siege is multi-threaded and can exert enough pressure on your site to quickly reveal its weaknesses.
Here is an example
siege
command for starting 100 sessions on an Escenic Community Expansion site, and creating 50 blogs in each session:$
$ siege -c 100 \ -r 50 \ -f siegedata-create-blog \ -H "Cookie:...."The actual HTTP request sent to the browser is read from a siege data file (
siegedata-create-blog
in the example above). These files have a very simple format, for example:http://mysite.com/community/addStory.do POST parameterOne=valueOne¶meterTwo=valueTwo...
They can easily be constructed by carrying out an operation in the browser and then using a debugger such as Firefox's Firebug to capture what is actually being sent to the server.
-
httperf for more testing more complex scenarios involving user input.
httperf
allows you to write session scripts that simulate the GET, PUT, POST and DELETE operations various kinds of user activity would result in. Furthermore, it can replay your Apache access logs, giving your tests real user traffic patterns as opposed to looping through a list of URLs sorted in alphabetical order.Here is an example that shows
httperf
creating 1000 connections and submitting 20 requests over each connection, establishing 100 connections per second:$
httperf\ --hog \ --server myserver.com \ --num-conn 1000 \ --ra 100 \ --num-calls=20See the
httperf
man pages for a detailed explanation of the parameters.
Once you have built up a library of tests, you can create a shell script to execute them all simultaneously. For example:
#! /usr/bin/env bash create_blog.siege & commit_poll_vote.siege & login_user.siege & replay_the_access_log.httperf &