Thursday, July 16, 2015

Web Server Load Testing Tool: Siege

What is Siege?
Siege is a benchmarking and load testing tool that can be used to measure the performance of a web server when under immense pressure. Siege performs following tests:
  • Amount of data transferred.
  • Response time of server.
  • Transaction rate.
  • Throughput.
  • Concurrency.
  • Times the program returned ok.
Siege provides three modes of operation:
  • Regression.
  • Internet Simulation.
  • Brute Force.
Note: The guide is only for Debian and Ubuntu servers.
1: Before installing any new program, update your server:
sudo apt-get update && sudo apt-get upgrade --show-upgraded

2: Download the latest version of Siege from Siege’s Website:
3: Unzip the file:
tar -zxvf siege-latest.tar.gz

4: Go to Siege directory:
cd siege-*/

5: Before configuration, if GNU compiler collection (gcc) is not installed, install now:
sudo apt-get install build-essential

6: Configure and complete the installation process:
sudo make install

7: Generate a configuration file:

8: After that open .siegerc file located in your home directory.
9: By default Siege configuration suggests 25 concurrent users over a period of 1 minute. Choose a location for your log file. Uncomment the variables shown below, and also if you want any other commented settings then don’t forget to remove the pound sign (#):
# Variable declarations. You can set variables here
# for use in the directives below. Example:
# 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

How to run Siege?

At last, now you are ready to run Siege!
To run Siege, enter the following command, replacing  with your IP address or domain name.
** 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.

Commands and further configuration of Siege

If the availability remains 100% with no failed connections then you are not in any problem.
URL file creation
If you want to test number of websites, configure the tool to read from a urls.txt .
1: Open the urls.txt  file located at /usr/local/etc/urls.txt. Add domain names, pages or IPs addresses to that file.
# URLS file for siege
# --
# Format the url entries in any of the following formats:
# http://www/index.html
# www/index.html
# Use the POST directive for pages that require it:
# POST ha=1&ho=2
#      or POST content from a file:
2: To run Siege with above mentioned file, enter the following command siege.
3: For separate file enter following command.
siege -f your/file/path.txt

For more information about Siege and it’s commands, visit their website: Siege Home.

No comments:

Post a Comment