Load test your website with Siege

Stress

Siege on the Battlefield

To understand how siege works, you first need to deploy a simple website. In this case, I use an Apache web server that comes with a default web page. In a basic test, Siege can be run with either the IP address of the target or its fully qualified domain name (FQDN). When invoked without options, Siege uses the default configuration in the siegerc file (i.e., the siege.conf file):

$ siege 192.168.56.11

As Figure 3 shows, Siege made a total of 29,068 transactions.

Figure 3: Running Siege against a single target.

Runtime can be controlled with the -t (--time) flag. The format is <NUM><m>, where <NUM> denotes the proposed time and <m> sets the unit of time to either S, M, or H (i.e., seconds, minutes, and hours).

To set the running time for each user to one minute (Figure 4), enter:

$ siege -t1M http://192.168.56.11
Figure 4: Setting the time for a Siege operation.

The default value of the number of users in a Siege operation is 25. However, you can override the number of simultaneous users hitting a server with the -c flag. To set this number to 30 (Figure 5), use the command:

$ siege -c 30 http://192.168.56.11
Figure 5: Setting the number of Siege users.

You can also use Siege to test multiple websites at once. For this, you need to create a file containing a list of the target sites. You can create such a file by going into a text editor, adding the URLs of target sites line by line, and saving the file:

$ nano ~/target-sites.txt
www.host1.com
192.168.56.12

As you can see, you can also use the target IP addresses. Now run Siege against these sites:

siege -f ~/target-sites.txt

The results are as shown in Figure 6.

Figure 6: Targeting multiple sites.

So far, the Siege command line has only comprised one or two arguments. However, you can also combine multiple operations in a single command (Figure 7),

siege -b -c 30 -t 30s 192.168.56.11
Figure 7: Combining multiple Siege operations.

where -b specifies the benchmark mode, -c sets the concurrency of connections (in this case, 30 users), and -t sets the runtime.

Interpreting the Results

Now that you have seen Siege in action, I'll explore some of the critical metrics reported in Figures 6 and 7.

Transactions represents the number of times Siege users hit a server. As mentioned earlier, the default is 25 users. If every user hits the server 10 times, the total transactions would include 250 hits. However, this metric also includes meta redirects and responses from multiple elements of a web page, which could result in a larger transaction rate value from that calculated.

Availability is the percentage of successful socket connections handled by the server. This percentage is derived from the ratio of the number of socket failures to total connection requests.

Response time is another important parameter that shows the average time a Siege user takes to respond to requests.

Transaction rate is basically the proportion of all the transactions to the total duration of the test.

Throughput is the mean traffic (in bytes per second) sent by the server to all simulated Siege users.

Conclusion

In this article, I looked at how Siege can be used to determine the potential of your website under stress. For you to fine-tune your website, you need to know how it's performing under various traffic conditions. Siege is a good choice for web developers who want to check the stability of their code.

Siege puts a lot of stress on the server, so you might experience system lag while trying to log in or while using the system. If you are new to or just learning about stress testing, Siege is a good tool to play around with; however, be cautious while running Siege in a production environment.

The Siege man page [3] contains a lot of useful information, so you should consult these pages to discover more about the possibilities of Siege.

Infos

  1. "Benchmarking," ITC 250 W14 3210 – Web App Programming 2 (retrieved October 20, 2022), https://canvas.seattlecentral.edu/courses/937693/pages/17-benchmarking?module_item_id=8157211
  2. Siege FTP page: https://download.joedog.org/siege/
  3. Siege man page: https://linux.die.net/man/1/siege
  4. The author on LinkedIn: https://www.linkedin.com/in/ali-imran-nagori/

The Author

Ali Imran Nagori is a technical writer and Linux enthusiast who loves to write about Linux systems administration and related technologies. He blogs at http://tecofers.com. Connect with him on LinkedIn [4].

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus