If you need to test more than one URL then you will need to tell Siege to use a file to load the URL’s from. Simply create a text file called urls.txt and add each URL you want to test on a separate line.
$ vim urls.txt http://www.mywebsite.com/about-us/ http://www.mywebsite.com/contact-us/
To tell Siege to use your urls.txt you need to use the -f parameter.
siege -v -c10 --reps=once -d5 -f urls.txt ** SIEGE 2.72 ** Preparing 10 concurrent users for battle. The server is now under siege... HTTP/1.1 200 0.61 secs: 7817 bytes ==> /about-us/ HTTP/1.1 200 0.66 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.67 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.67 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.72 secs: 7818 bytes ==> /about-us/ HTTP/1.1 200 0.74 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.78 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.60 secs: 8050 bytes ==> /contact-us/ HTTP/1.1 200 0.60 secs: 8050 bytes ==> /contact-us/ HTTP/1.1 200 0.63 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.68 secs: 7819 bytes ==> /about-us/ HTTP/1.1 200 0.69 secs: 7821 bytes ==> /about-us/ HTTP/1.1 200 0.61 secs: 8052 bytes ==> /contact-us/ HTTP/1.1 200 0.60 secs: 8046 bytes ==> /contact-us/ HTTP/1.1 200 0.61 secs: 8043 bytes ==> /contact-us/ HTTP/1.1 200 0.62 secs: 8051 bytes ==> /contact-us/ HTTP/1.1 200 0.60 secs: 8044 bytes ==> /contact-us/ HTTP/1.1 200 0.61 secs: 8052 bytes ==> /contact-us/ HTTP/1.1 200 0.65 secs: 8051 bytes ==> /contact-us/ HTTP/1.1 200 0.62 secs: 8051 bytes ==> /contact-us/ done. Transactions: 20 hits Availability: 100.00 % Elapsed time: 9.32 secs Data transferred: 0.15 MB Response time: 0.65 secs Transaction rate: 2.15 trans/sec Throughput: 0.02 MB/sec Concurrency: 1.39 Successful transactions: 20 Failed transactions: 0 Longest transaction: 0.78 Shortest transaction: 0.60
As you can see, Siege has requested both URL’s from the file at random intervals.
The author of Siege, Jeffrey Fulmer (see the siege website) has also written a companion program to Siege called ‘sproxy’. Quite simple, sproxy logs all urls to a text file for use with Siege. To do this you need to tell your web browser to connect to the proxy and then simply load your webpage.
Unlike Siege, sproxy doesn’t appear to be packaged for Ubuntu, so we need to compile and install it.
$ curl http://www.joedog.org/pub/sproxy/sproxy-latest.tar.gz -o sproxy-latest.tar.gz $ tar xvfz sproxy-latest.tar.gz $ cd sproxy-1.02/ $ ./configure $ make $ sudo make install
Once sproxy is installed you should configure your browser to use the proxy. In Firefox, go to Preferences > Advanced > Network and click the ‘settings’ button. Then select ‘Manual Proxy Configuration’ and enter ‘127.0.0.1’ in the ‘HTTP Proxy:’ field, and ‘9001’ in the Port Field. Once you have done this, click ‘OK’ and close your Preferences dialog. [screenie]
Go to your terminal and launch sproxy. By default it will bind to the localhost and use port 9001. Now go to your browser and load a single page on your website. When it has finished loading, go back to your terminal and quit sproxy using CTRL-C.
[email protected] ~ $ sproxy SPROXY v1.02 listening on port 9001 ...appending HTTP requests to: /home/andrew/urls.txt ...default connection timeout: 120 seconds ^C [email protected] ~ $
Once you’ve cleaned your urls.txt file you can then siege it as we did previously. This time we’ll simulate one user making one request of the whole web page, assets and all.
siege -c1 --reps=once -f urls.txt ** SIEGE 2.72 ** Preparing 1 concurrent users for battle. The server is now under siege.. done. Transactions: 38 hits Availability: 100.00 % Elapsed time: 26.23 secs Data transferred: 0.38 MB Response time: 0.19 secs Transaction rate: 1.45 trans/sec Throughput: 0.01 MB/sec Concurrency: 0.27 Successful transactions: 38 Failed transactions: 0 Longest transaction: 0.62 Shortest transaction: 0.10
Siege, by default, requests each URL from the server regardless of any expiry headers sent by the server. This allows us to simulate a page load with an empty cache but we can also configure Siege to request the URLs and respect any expires headers that are sent. To do this, open your ~/.siegerc file in your text editor and find the Cache revalidation section (around line 101 in my file). Simply change the line to ‘cache = true’, save it and re-run your test, this time with the -v flag.
Based in Staffordshire, UK