« Back to Index

Siege load/stress testing utility (https://www.joedog.org/siege-manual/)

View original Gist on GitHub

1. siege.sh

# brew install siege

# -c/--concurrent == number of concurrent requests
# -r/--reps == number of times to run the test

siege -c 10 -r 10 -b "http://www.domain.com/"

# Note: doesn't always work with SSL endpoints with self-signed certs
#       using Apache Ab in a Docker container seems to do the trick though
#       see https://gist.github.com/Integralist/01815f7abc7d18a97341

siege --header "Content-Type: application/json" \
      --get \
      --concurrent 2\
      --reps 5\
      'https://requester.mozart.int.api.bbci.co.uk/collect POST {"components":[{"id":"A","endpoint":"https://morph.int.api.bbci.co.uk/data/orb-webservice-header","must_succeed":true}]}'
      
# `--get` is useful for debugging purposes as it returns the HEADERS from the POST
# the above POST will send 10 requests in total

# One-liner
siege -H "Content-Type: application/json" -g -c 2 -r 5 'https://requester.mozart.int.api.bbci.co.uk/collect POST {"components":[{"id":"A","endpoint":"https://morph.int.api.bbci.co.uk/data/orb-webservice-header","must_succeed":true}]}'

# There are more options available when using a `.siegerc` file...
# the other flags stop working once you specify -R
siege -R .siegerc -H "Content-Type: application/json" 'https://requester.mozart.int.api.bbci.co.uk/collect POST {"components":[{"id":"A","endpoint":"https://morph.int.api.bbci.co.uk/data/orb-webservice-header","must_succeed":true}]}'

# Auto generate a .siegerc file
siege.config

# View current settings in the .siegerc file
siege -C

2. .siegerc

# Updated by Siege 3.1.3, January-11-2016
# Copyright 2000-2015 by Jeffrey Fulmer, et al.
# 
# Siege configuration file -- edit as necessary
# For more information about configuring and running
# this program, visit: http://www.joedog.org/

#
# 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)/var/siege.log

#
# Verbose mode
#
# Signify verbose mode, true turns on verbose output
# ex: verbose = true|false
#
verbose = true

#
# Quiet mode
#
# When true, this turns off verbose and standard output.
# You'll still see the opening announcement and the final
# stats if you're running a siege but -g/--get will be
# extremely quiet. This was added primarily for scripting
# ex: quiet = true|false
#
quiet = false

#
# Get method - select an HTTP method to use when siege 
# is set to get mode, siege -g/--get URL. You may select
# GET or HEAD.  The default method is HEAD. As expected
# HEAD prints just the headers and GET prints the entire 
# page. 
#
# NOTE: This only applies when siege is invoked with
# -g/--get.  All other requests methods will be made
# on the basis of the URL. 
# 
# example: gmethod = GET
# 
gmethod = HEAD


#
# CSV Verbose format: with this option, you can choose 
# to format verbose output in traditional siege format 
# or comma separated format. The latter will allow you 
# to redirect output to a file for import into a spread
# sheet, i.e., siege > file.csv 
# ex: csv = true|false (default false)
#
# csv = true

#
# Timestamp format: with this option, you can choose to
# print a timestamp each line of output
# example: timestamp = true|false (default false)
#
# sample: [Sat, 2010-11-20 10:39:13] HTTP/1.1 200   0.12 secs:    4003 bytes ==> / 
# 
# timestamp = true

#
# Full URL verbose format: By default siege displays
# the URL path and not the full URL. With this option, 
# you # can instruct siege to show the complete URL.
# ex: fullurl = true|false (default false)
# 
# fullurl = true

#
# Display id: in verbose mode, display the siege user
# id associated with the HTTP transaction information
# ex: display-id = true|false
#
# display-id = 

#
# Limit: This directive places a cap on the number of
# threads siege will generate. The default value is 255 
# because out of the box apache is configured to handle
# 256 clients. If you schedule more clients than apache
# can handle, requests will back up and you'll make a 
# mess. DO NOT INCREASE THIS NUMBER UNLESS YOU CONFIGURED
# APACHE TO HANLDE MORE THAN 256 SIMULTANEOUS REQUESTS
# ex: limit = 1023 (default is 255)
# 
limit = 255

#
# Show logfile location.  By default, siege displays the
# logfile location at the end of every run when logging
# You can turn this message off with this directive.
# ex: show-logfile = false
#
show-logfile = true

#
# Default logging status, true turns logging on.
# ex: logging = true|false
#
logging = true

#
# Logfile, the default siege logfile is $PREFIX/var/siege.log
# This directive allows you to choose an alternative log file.
# Environment variables may be used as shown in the examples:
# ex: logfile = /home/jeff/var/log/siege.log
#     logfile = ${HOME}/var/log/siege.log
#     logfile = ${LOGFILE}
#
# logfile = 

#
# HTTP protocol.  Options HTTP/1.1 and HTTP/1.0.
# Some webservers have broken implementation of the
# 1.1 protocol which skews throughput evaluations.
# If you notice some siege clients hanging for
# extended periods of time, change this to HTTP/1.0
# ex: protocol = HTTP/1.1
#     protocol = HTTP/1.0
#
protocol = HTTP/1.1

#
# Chunked encoding is required by HTTP/1.1 protocol
# but siege allows you to turn it off as desired.
# 
# ex: chunked = true 
# 
chunked = true

# 
# Cache revalidation.
# Siege supports cache revalidation for both ETag and 
# Last-modified headers. If a copy is still fresh, the 
# server responds with 304. 
# HTTP/1.1 200   0.00 secs:    2326 bytes ==> /apache_pb.gif
# HTTP/1.1 304   0.00 secs:       0 bytes ==> /apache_pb.gif
# HTTP/1.1 304   0.00 secs:       0 bytes ==> /apache_pb.gif
# 
# ex: cache = true
#
cache = false

#
# Connection directive. Options "close" and "keep-alive"
# Starting with release 2.57b3, siege implements persistent 
# connections in accordance to RFC 2068 using both chunked
# encoding and content-length directives to determine the 
# page size. To run siege with persistent connections set
# the connection directive to keep-alive. (Default close)
# CAUTION: use the keep-alive directive with care.
# DOUBLE CAUTION: this directive does not work well on HPUX
# TRIPLE CAUTION: don't use keep-alives until further notice
# ex: connection = close
#     connection = keep-alive
#
connection = close

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

#
# 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 =

#
# Repetitions.  The length of siege may be specified in client
# reps rather then a time duration.  Instead of specifying a time
# span, you can tell each siege instance to hit the server X number
# of times.  So if you chose 'reps = 20' and you've selected 10 
# concurrent users, then siege will hit the server 200 times.
# ex: reps = 20
#
# reps = 

#
# Default URLs file, set at configuration time, the default
# file is PREFIX/etc/urls.txt.  So if you configured siege
# with --prefix=/usr/local then the urls.txt file is installed
# int /usr/local/etc/urls.txt.  Use the "file = " directive to
# configure an alternative URLs file. You may use environment
# variables as shown in the examples below:
# ex: file = /export/home/jdfulmer/MYURLS.txt
#     file = $HOME/etc/urls.txt
#     file = $URLSFILE
#
# file =

#
# Default URL, this is a single URL that you want to test. This
# is usually set at the command line with the -u option.  When
# used, this option overrides the urls.txt (-f FILE/--file=FILE)
# option. You will HAVE to comment this out for in order to use
# the urls.txt file option.
#
# NOTE: you may do the same thing by passing a URL to siege at 
# the command line: siege -c10 -r10 "www.joedog.org/"
# Generally, it's a good idea to wrap a command line URL in quotes
#
# ex: url = https://shemp.whoohoo.com/docs/index.jsp
#
# url =

#
# Default delay between each request by a single thread. This 
# value is not included in the request time. If a thread sleeps 
# for two seconds then completes a 0.5 second request, the time
# of the request is 0.5 seconds, not 2.5 seconds.
#
# ex: delay = 0.5
#
delay = 1

#
# Connection timeout value. Set the value in seconds for 
# socket connection timeouts. The default value is 30 seconds.
# ex: timeout = 30
#
# timeout = 

#
# Session expiration: This directive allows you to delete all
# cookies after you pass through the URLs. This means siege will
# grab a new session with each run through its URLs. The default
# value is false.
# ex: expire-session = true
#
# expire-session = 

#
# Cookie support: by default siege accepts cookies. This directive
# is available to disable that support. Set cookies to 'false' to
# refuse cookies. Set it to 'true' to accept them. The default value 
# is true.
# ex: cookies = false
#
# cookies = 

#
# Failures: This is the number of total connection failures allowed
# before siege aborts. Connection failures (timeouts, socket failures, 
# etc.) are combined with 400 and 500 level errors in the final stats, 
# but those errors do not count against the abort total.  If you set 
# this total to 10, then siege will abort after ten socket timeouts, 
# but it will NOT abort after ten 404s. This is designed to prevent 
# a run-away mess on an unattended siege. The default value is 1024
# ex: failures = 50
#
# failures = 

#
# Internet simulation. If true, siege clients will hit
# the URLs in the urls.txt file randomly, thereby simulating
# internet usage.  If false, siege will run through the 
# urls.txt file in order from first to last and back again.
# ex: internet = true
#
internet = false

#
# Default benchmarking value, If true, there is NO delay
# between server requests, siege runs as fast as the web
# server and the network will let it.  Set this to false 
# for load testing.
# ex: benchmark = true
# 
benchmark = false

#
# Set the siege User-Agent to identify yourself at the
# host, the default is: JoeDog/1.00 [en] (X11; I; Siege #.##) 
# But that wreaks of corporate techno speak.  Feel free
# to make it more interesting :-)  Since Limey is recovering
# from minor surgery as I write this, I'll dedicate the 
# example to him...
#
# ex: user-agent = Limey The Bulldog
# 
# user-agent =

#
# Accept-encoding. This option allows you to specify 
# acceptable encodings returned by the server. Use this
# directive to turn on compression. By default we accept
# gzip compression.
#
# ex: accept-encoding = *
#     accept-encoding = gzip
#     accept-encoding = compress;q=0.5;gzip;q=1
accept-encoding = gzip

#
# URL escaping was added in version 3.0.3. You may use this
# directive to turn off this experimental feature. By default
# this feature is active by default starting with v3.0.3
#
# http://www.joedog.org/jukebox.php?band=the days of new
# becomes:
# http://www.joedog.org/jukebox.php?band=the%20days%20of%20the%20new 
#
# ex: url-escaping = false
#
url-escaping = true

#
# TURN OFF THAT ANNOYING SPINNER!
# Siege spawns a thread and runs a spinner to entertain you
# as it collects and computes its stats. If you don't like 
# this feature, you may turn it off here. Your JoeDog loves 
# this feature but he understands that it may not render well
# in your particular terminal.  It's on by default because who
# doesn't love a good spinner! 
#
# ex: spinner = false 
#
spinner = true

#
# WWW-Authenticate. Currently siege supports two types
# of HTTP authentication: digest and basic. It has partial 
# support for Microsoft's NTLM but in practice that only 
# works with the -g/--get option. (as of siege 3.1.1)
# 
# When siege makes a request for a page that requires user
# authentication, it will search its logins for a matching
# realm. If it finds credentials for a realm, it will attempt
# to login with that username and password.
#
# If it fails to match the realm, it will use its default login
# credentials (which are designated with the keyword "all" or no
# specified realm. 
#
# If you do not supply a realm, then it will default to "all"
# which instructs siege to send as default.
# 
# You may enter many logins with each on its own separate line. 
# The only limitation is memory and realm name. You can't use the
# same realm name more than once.  
#
# ex: login = jdfulmer:topsecret:Admin
#     login = jeff:supersecret:all 
#     login = jeff:supersecret
#
# login = 

#
# 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 = http://eos.haha.com/login.jsp POST name=jeff&pass=foo
#
# Siege versions after 2.69 support multi logins; you can configure 
# them with multiple login-url directives. Place each one on a separate 
# line. Siege loops through each login then starts again at the beginning 
# after it uses the last one. If you have more users than login-urls, then 
# siege starts reassigning ones that have already been used. 
# 
# ex: login-url = http://www.haha.com/login.php?name=homer&pass=whoohoo
#     login-url = http://www.haha.com/login.php?name=marge&pass=ohhomie
#     login-url = http://www.haha.com/login.php?name=bart&pass=eatMyShorts
#
# login-url = 

#
# FTP login - This directive provides one of two ways 
# to login to an ftp server. You may also set credentials 
# in RFC-1738 format: ftp://user:pass@host.com/ink.jpg
#
# The format is USER:PASS:HOST separated by colon ':'
# The host field is optional. If you don't set a host,
# then siege will send the same user:pass to every FTP
# server. You may use this directive MULTIPLE times. 
# Siege will store each instance in memory and send the
# appropriate credentials at login time depending on the
# hostname in the URL.
#
# ex: ftp-login: jdfulmer:whoohoo:ftp.joedog.org
#     ftp-login: jdfulmer:password
#
# ftp-login = 

# 
# FTP unique - This directive determines whether siege 
# will upload files with the same name (and therefore 
# overwrite whatever is on disk) or upload files each with a
# unique name. If true, siege will rewrite the file name with 
# a timestamp in its name, i.e., p.jpg => p-3086060432.jpg
# The default value is true.
#
# ex: unique = false
# 
unique = true

#
# ssl-cert
# This optional feature allows you to specify a path to a client
# certificate. It is not neccessary to specify a certificate in
# order to use https. If you don't know why you would want one, 
# then you probably don't need this feature.  Use openssl to 
# generate a certificate and key with the following command:
#   $ openssl req -nodes -new -days 365 -newkey rsa:1024 \
#                 -keyout key.pem -out cert.pem
# Specify a path to cert.pem as follows:
# ex: ssl-cert = /home/jeff/.certs/cert.pem
#
# ssl-cert = 
 
#
# ssl-key
# Use this option to specify the key you generated with the command
# above. ex: ssl-key = /home/jeff/.certs/key.pem 
# You may actually skip this option and combine both your cert and 
# your key in a single file:
#   $ cat key.pem > client.pem
#   $ cat cert.pem >> client.pem
# Now set the path for ssl-cert:
# ex: ssl-cert = /home/jeff/.certs/client.pem
# (in this scenario, you comment out ssl-key)
#
# ssl-key = 

#
# ssl-timeout 
# This option sets a connection timeout for the ssl library
# ex: ssl-timeout = 30
# 
# ssl-timeout = 

#
# ssl-ciphers
# You can use this feature to select a specific ssl cipher
# for HTTPs. To view the ones available with your library run
# the following command: openssl ciphers
# ex: ssl-ciphers = EXP-RC4-MD5
#
# ssl-ciphers = 

#
# Proxy Host. You can use siege to test a proxy server but
# you need to configure it to use one. You'll need to name
# a proxy host and the port it's listening one. The settings
# are proxy-host and proxy-port. The following example shows
# how to use them.
# ex: proxy-host = proxy.joedog.org
#     proxy-port = 3123
#
# proxy-host =
# proxy-port =

#
# Proxy-Authenticate. When scout hits a proxy server which
# requires username and password authentication, it will this
# username and password to the server. The format is username,
# password and optional realm each separated by a colon. You
# may enter more than one proxy-login as long as each one has
# a different realm. If you do not enter a realm, then scout
# will send that login information to all proxy challenges. If
# you have more than one proxy-login, then scout will attempt
# to match the login to the realm.
# ex: proxy-login: jeff:secret:corporate
#     proxy-login: jeff:whoohoo
#
# proxy-login = 

#
# Redirection support.  This option allows to to control
# whether a Location: hint will be followed.  Most users
# will want to follow redirection information, but sometimes
# it's desired to just get the Location information.
#
# ex: follow-location = false
#
# follow-location = 

# Zero-length data.  siege can be configured to disregard
# results in which zero bytes are read after the headers.
# Alternatively, such results can be counted in the final
# tally of outcomes.
#
# ex: zero-data-ok = false 
#
# zero-data-ok =

#
# end of siegerc