Categories
Testing

Siege Stress Testing

Download and Configure Siege

  1. sudo apt-get update && sudo apt-get upgrade --show-upgraded
  2. Download the latest version of Siege at Siege’s website:wget http://download.joedog.org/siege/siege-latest.tar.gz
  3. Extract: tar -zxvf siege-latest.tar.gz
  4. cd siege-*/
  5. Install GNU Compiler Collection (gcc):sudo apt-get install build-essential
  6. Configure:./configure make sudo make install
  7. Generate a configuration file:siege.config
  8. Open the .siegerc file located in your home directory.
  9. The suggested Siege configuration is for 25 concurrent users over a period of 1 minute. Set a location for your log file: ~/.siegerc
...

        #
        # Variable declarations. You can set variables here
        # for use in the directives below. Example:
        # PROXY = proxy.joedog.org
        # Reference variables inside ${} or $(), example:
        # proxy-host = ${PROXY}
        # You can also reference ENVIRONMENT variables without
        # actually declaring them, example:
        logfile = $(HOME)/siege.log

...

        #
        # Default number of simulated  concurrent users
        # ex: concurrent = 25
        #
        concurrent = 25

        #
        # Default duration of the siege.  The right hand argument has
        # a modifier which specifies the time units, H=hours, M=minutes,
        # and S=seconds. If a modifier is not specified, then minutes
        # are assumed.
        # ex: time = 50M
        #
        time = 1M

Siege is ready now!

Run Siege

Example URL: www.example.com

siege www.example.com

Siege outputs the results:

** SIEGE 2.70
** Preparing 25 concurrent users for battle.
The server is now under siege...
Lifting the server siege...      done.
Transactions:               2913 hits
Availability:             100.00 %
Elapsed time:              59.51 secs
Data transferred:           0.41 MB
Response time:              0.00 secs
Transaction rate:          48.95 trans/sec
Throughput:              0.01 MB/sec
Concurrency:                 0.04
Successful transactions:         2913
Failed transactions:                0
Longest transaction:             0.01
Shortest transaction:            0.00

FILE: /var/log/siege.log
You can disable this annoying message by editing
the .siegerc file in your home directory; change
the directive 'show-logfile' to false.

If there are no failed connections and the availability remains at 100%, there are no problems.

Advanced Configuring

Creating a URL File

If you want Siege to hit a number of pages on your website at random, configure the program to read from a urls.txt file that lists the selected pages.

  • Open the urls.txt file generally created at /usr/local/etc/urls.txt. Add a list of URLs or IP addresses to that file:/usr/local/etc/urls.txt
# URLS file for siege
# --
# Format the url entries in any of the following formats:
# http://www.whoohoo.com/index.html
# http://www/index.html
# www/index.html
# http://www.whoohoo.com/cgi-bin/howto/display.cgi?1013
# Use the POST directive for pages that require it:
# http://www.whoohoo.com/cgi-bin/haha.cgi POST ha=1&ho=2
#      or POST content from a file:
# http://www.whoohoo.com/melvin.jsp POST </home/jeff/haha
# http://www.whoohoo.com/melvin.jsp POST <./haha
# You may also set and reference variables inside this file,
# for more information, man urls_txt
# -------------------------------------------------------

www.example.com
www.example.org
123.45.67.89
  • To run Siege with this file use the siege command:siege If using a separate file, run:siege -f your/file/path.txt

Commands

Siege features a number of command line options to use when you want to deviate from the default configuration but do not wish to edit the file.

  • -c [num]: Set the number of concurrent users.
  • -t [num]: Set a time limit for which Siege runs. Siege can run with the modifiers s for seconds, m for minutes, or h for hours. There should be no space between the number and the modifier (-t10s not -t10 s).
  • -d [num]: Set the delay for each Siege user. Each user is then delayed for a random amount of seconds in between 1 and the set number. The default value is 3.
  • -i: Used in conjunction with a URLs file, this causes each user to randomly hit one of the URLs, with no predetermined pattern. Similar to real life (the ‘i’ stands for “internet”), where you will not know where site visitors go, not all pages may be hit.
  • -v: Verbose output. This outputs the results Siege gets in real time before printing the final results.
  • -f [file]: Run Siege with a file containing a list of URLs that is not the default urls.txt file.
  • -g [url]: Pull down the HTTP headers.
  • -l: Generates a log file.
  • -m "[message]": Include a message in the log file.
  • -C: Outputs Siege’s current configuration profile.
  • -V: Outputs Siege’s version information.
  • -h: Outputs help information.