Testing The Load of Web Servers with Siege Benchmark Tool

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Siege is an open source regression test and benchmark utility. It can stress test a single URL with a user defined number of simulated users, or it can read many URLs into memory and stress them simultaneously. The program reports the total number of hits recorded, bytes transferred, response time, concurrency, and return status. Siege supports HTTP/1.0 and 1.1 protocols, the GET and POST directives, cookies, transaction logging, and basic authentication. Its features are configurable on a per user basis.

Most features are configurable with command line options which also include default values to minimize the complexity of the program’s invocation. So Siege allows you to stress a web server with n number of users t number of times, where n and t are defined by the user. It records the duration time of the test as well as the duration of each single transaction. It reports the number of transactions, elapsed time, bytes transferred, response time, transaction rate, concurrency and the number of times the server responded OK, that is status code 200.

Also Siege should only be ran against servers you own or on such you have explicit permission to test. In some countries, using siege on unauthorized websites can be considered a crime.

INSTALLATION

Siege was built with GNU autoconf. If you are familiar with GNU software, then you should be comfortable installing siege Please consult the file INSTALL for more details.

To install Siege under Debin/Ubuntu, you can do this with command:

$ sudo apt install siege

For CentOS/RHEL, Install and enable epel repository to install siege :

# yum install epel-release
# yum install siege

Also You can build the Siege from source.For that purpose you will need to have build-essential and development packages installed.

For Debian/Ubuntu
$ sudo apt install build-essential  

For CentOS/RHEL   
# yum groupinstall 'Development Tools'  

Then download Siege and install from sources as shown.

[root@unixcop ~]# wget http://download.joedog.org/siege/siege-latest.tar.gz
--2021-08-24 07:12:17--  http://download.joedog.org/siege/siege-latest.tar.gz
Resolving download.joedog.org (download.joedog.org)... 52.24.24.107
Connecting to download.joedog.org (download.joedog.org)|52.24.24.107|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 543378 (531K) [application/x-gzip]
Saving to: ‘siege-latest.tar.gz’

100%[============================================================================================================>] 543,378     --.-K/s   in 0.1s    

2021-08-24 07:12:18 (4.57 MB/s) - ‘siege-latest.tar.gz’ saved [543378/543378]

[root@unixcop ~]#

Then extract it:

$ tar -zxvf siege-latest.tar.gz

Also go to the extracted directory and install it with:

$ cd siege-*/
$ sudo ./configure --prefix=/usr/local --with-ssl=/usr/bin/openssl
$ sudo make && make install

Configuring Siege

Once you have completed the installation, you can adjust your siege configuration file. It is located in /etc/siege/siegerc. In case you have decided to build the package from source, you will have to run:

$ siege.config

In addition to, This will generate siege.conf file located in your user’s home ~/.siege/siege.conf.

The contents of the file should look something like this. Note that I have uncomment the logfile and time directives:

[root@unixcop siege]# cat siegerc |egrep -v "^$|#"
verbose = true
color = on
quiet = false
json_output = false
show-logfile = true
logging = false
logfile = ${HOME}/siege.log
gmethod = HEAD
parser = true
nofollow = ad.doubleclick.net
nofollow = pagead2.googlesyndication.com
nofollow = ads.pubsqrd.com
nofollow = ib.adnxs.com
limit = 255
protocol = HTTP/1.1
chunked = true
cache = false
connection = close
concurrent = 25
delay = 0.0 
internet = false
benchmark = false
accept-encoding = gzip, deflate
url-escaping = true
unique = true
 
[root@unixcop siege]#

Also With the current configuration, siege will imitate 25 concurrent users over 1 minute.

You are now ready to run your siege.

Testing Website Load with Siege

You only need to specify the website you wish to test like this:

# siege example.com
 
[root@unixcop .siege]# siege 192.168.13.133/unixcop
[alert] Zip encoding disabled; siege requires zlib support to enable it
** SIEGE 4.1.1
** Preparing 25 concurrent users for battle.
The server is now under siege...
Lifting the server siege...
Transactions:		         6457 hits
Availability:		      100.00 %
Elapsed time:		        1.45 secs
Data transferred:	       11.51 MB
Response time:		        0.05 secs
Transaction rate:	      453.10 trans/sec
Throughput:		        7.94 MB/sec
Concurrency:		       24.20
Successful transactions:         672
Failed transactions:	           0
Longest transaction:	        0.24
Shortest transaction:	        0.02
 
[root@unixcop .siege]# 

If the availability remains at 100% and there are no failed connections, your system did well and there were no issues. You should also keep an eye on the response time.

Run Siege with Multiple Websites

You can test multiple URLs, by setting siege to read them from file. You can describe the URLs in /usr/local/etc/urls.txt like this:

[root@unixcop ~]# cd /usr/local/etc/
[root@unixcop etc]# cat 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 assign and reference variables inside this file:
# HOST=www.joedog.org
# PROT=https  # Secure protocol
# PORT=443    # Default https port
# 
# $(PROT)://$(HOST):$(PORT)/siege/jsoner.php?haha=papa
# $(PROT)://$(HOST)/siege/jsoner.php?day=%2332
# $(PROT)://$(HOST)/siege/jsoner.php POST {haha:papa}
# 
# Since $ is used to prefix scalar variables, you have to escape 
# them if you want to pass them to the server: 
# $(PROT)://$(HOST)/siege/jsoner.php?amount=\$10.00&cost=\$12.99
# -------------------------------------------------------

[root@unixcop etc]#

Also to tell siege to test the URLs from the file, use the -f option like this:

# siege -f /usr/local/etc/urls.txt

You can also use command line options:

Options:
-V,     --version VERSION, prints the version number.
-h,     --help HELP, prints this section.
-C,     --config CONFIGURATION, show the current config.
-v,     --verbose VERBOSE, prints notification to screen.
-q,     --quiet QUIET turns verbose off and suppresses output.
-g,     --get GET, pull down HTTP headers and display the transaction. Great for application debugging.
-p,     --print PRINT, like GET only it prints the entire page.
-c,      --concurrent=NUM CONCURRENT users, default is 10
-r,      --reps=NUM REPS, number of times to run the test.
-t,     --time=NUMm TIMED testing where "m" is modifier S, M, or H
ex:   --time=1H, one hour test.
-d,    --delay=NUM Time DELAY, random delay before each request
-b,    --benchmark BENCHMARK: no delays between requests.
-i,      --internet INTERNET user simulation, hits URLs randomly.
-f,      --file=FILE FILE, select a specific URLS FILE.
-R,     --rc=FILE RC, specify an siegerc file
-l,      --log[=FILE] LOG to FILE. If FILE is not specified, the default is used: PREFIX/var/siege.log
-m,    --mark="text" MARK, mark the log file with a string. between .001 and NUM. (NOT COUNTED IN STATS)
-H,    --header="text" Add a header to request (can be many)
-A,    --user-agent="text" Sets User-Agent in request
-T,     --content-type="text" Sets Content-Type in request
-j,      --json-output JSON OUTPUT, print final stats to stdout as JSON
         --no-parser NO PARSER, turn off the HTML page parser
        --no-follow NO FOLLOW, do not follow HTTP redirects

Conclusion

Siege is a powerful tool to measure your system reliability when under high load. You should always run your tests with caution as the tested server may become inaccessible during the evaluation. Tags

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook