How to perform HTTP load testing using Siege

Sometimes it is important to load test your application and server. There are many benefits of HTTP load testing. By performing load testing, you can know how your server and your application will perform under pressure.

You can also know how much load or traffic it would take before your application starts facing downtime or issues. So, It’s important to perform HTTP load testing on your server and application.

In this short tutorial, I will show you how you can perform these tests on your server using a free tool called Siege. Siege is an HTTP load testing tool that you can use to send hundreds of concurrent visitors on your website at once to check how it will perform under pressure and how much availability your server can provide.

Siege is a very easy to use and beginner-friendly tool. It just takes a few commands to install Siege on Ubuntu server and a single command to start testing the performance of your application.

After the test is complete, it provides us the useful information like Availability, Number of successful requests, Number of failed requests, and much more.

Now, We can get started with the tutorial by installing Siege on our Ubuntu server.

Install Siege on Ubuntu

It is a very easy task to install Siege on our Ubuntu server. Execute the following command to install siege on Ubuntu.

$ sudo apt-get install siege -y

It might take a minute or two to install and configure Siege on the server. Once done, Siege is ready to use. It does not require any extra configuration except in some cases. We will discuss custom configuration later in this tutorial. For now, Let’s run our first load test using Siege

HTTP Load Testing on Single URL

We do not recommend you to run the load test directly on your website. However, you can clone your website on the identical server and then you can run the test so that the real visitors of your website do not face issues while the tests are going on.

Here is the syntax of the siege command.

siege [options] <URL>

The options are optional. You can just run siege command with URL and it will still work. There are many useful options that you can use with the command to perform tests under different conditions. We will take a few cases and run a few tests under different conditions to learn how to use this tool practically.

Execute the following command to run a test without any options. If you do not specify how many concurrent visitors you want to send on your site, Siege will send 15 concurrent visitors. And the time will be indefinite, It means that the test will run until you abort it.

$ sudo siege https://example.com

Execute the following command with -t option to specify the time duration for which you want to run the test. The time can be in minutes, hours or seconds. For example, -t2M or -t2 will run a test for two minutes, -t1H will run a test for 1 hour and -t20S will run a test for 20 seconds.

$ sudo siege -t1 https://example.com # It will run the test for 1 minute

Execute the following command with -c option to specify concurrent visitors. The number of concurrent visitors is capped at 255 by default but you can update the maximum concurrent users by editing the siege configuration file.

$ sudo siege -t1 -c100 https://example.com # It will run the test for 1 minute with 100 concurrent visitors

Execute the following command to run the test in verbose mode. In verbose mode, you will be able to see each request on your screen.

$ sudo siege -t1 -c10 -v https://example.com

HTTP Load testing on Multiple URLs

You can also perform load testing on multiple URLs randomly using Siege. Siege provides an option called -f that you can use to load URLs from the file to send requests randomly on those URLs.

For example, Let’s create an imaginary file with name urls.txt and content as follows.

https://example.com/url1
https://example.com/about
https://example.com/contact
https://example.com/something-else

As you can see, we have created a simple text file containing the URLs of our site, one per line. Now, we can execute the following command to send requests randomly on these URLs.

$ sudo siege -t1 -c100 -f urls.txt

This way, you can run tests on multiple URLs at once to randomize the test. This way, you can simulate real users on the site to check how your site will perform under such loads.

 

There are many other options available with Siege that you can use to test in a more random way. For example, you can send the custom user agent using the -A option to avoid these requests being displayed on your log monitoring system. You can use the -m option to mark logs with a specific string to filter out the logs from a specific test run. If you want to send a specific header with your requests, you can use -H option followed by header in the double quotes.

 

Conclusion: So, this is how you can use Siege to perform HTTP load testing on your server and application. We recommend you to run these tests only on the applications you own. As it can send hundreds of requests at once, It is also recommended to avoid running unwanted tests.

Let us know if you need help with Siege in the comment section given below. We will respond with the solution or answer as soon as possible.

Leave a Reply