Siege is an open-source multi-threaded regression test and benchmark utility with a primary focus on load testing and benchmarking. It can stress test a single URL with a user-defined number of simulated users or 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.
At the end of this guide, you will know how to install siege on your Ubuntu 20.04 LTS Focal Fossa operating system in the following guide. The same principle will work for the newer version Ubuntu 21.04 (Hirsute Hippo).
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04 and Linux Mint 20)
- User account: A user account with sudo or root access.
Check and update your Ubuntu 20.04 operating system.
sudo apt update && sudo apt upgrade -y
Install Siege Benchmarking Tool
Ubuntu comes with Siege in its default repositories and is fairly up to date, given the software doesn’t change as often as some other software given its simple program nature. To install Siege execute the following command:
sudo apt install siege -y
Confirm the siege version to make sure it’s installed and to compare it to the current version from Siege’s official website.
Firstly, the most common commands for using Siege with Ubuntu 20.04 is as below:
- -t : This option is used to set a time limit for which Siege runs.
- -c : This option is used to set the number of concurrent users.
- -d : This option is used to set the delay time for each user.
- -C : This option is used to specify your own configuration file.
- -i : It is used to hit random URLs.
- -T : It is used to set the Content-Type in requests.
- -h : It is used to display help information.
- -l : It is used to generate a log file.
Setting up Siege is quite simple, as most defaults are fine. The main option you will need to change is the log path.
First, open up the configuration file using nano editor:
sudo nano /etc/siege/siegerc
Find and uncomment the line (# logfile = $(HOME)/var/log/siege.log):
Test Website with Siege (Live test)
Now it’s time actually to test your web server, do note this will pretty much look like a DDOS attack to some firewalls and WAF’s so make sure to have permission before using any HTTP benchmarking tool, if not your own server.
To execute the test, enter the following:
siege https://www.example.com -t 1m
This will stress test with the default 25 concurrent users for 1 minute. You will see the following output:
Once the benchmark is complete, you will see the results:
Note, normally, and you would run for 5 to 15 minutes. The 1minute was just an example for the guide. You probably won’t get a good stress test from only doing 60 seconds.
Next, another variable you may want to include is the number of workers. Example command:
siege https://www.example.com -c 100 -t 2m
This time, the addition of (-c) is for concurrent users. You can specify this on the fly for different testing.
Now in the configuration file, you can edit the time, concurrent users, data, timestamps if you have a specific test you run daily on your sites.
Test Multiple Websites with Siege
Another handy feature if you a sysadmin or managing multiple domains and sites is using the multiple siege feature in the following file (/etc/siege/urls.txt).
Open the file with nano:
sudo nano /etc/siege/urls.txt
Next, add the URLs you want to be benchmark tested:
To save the file (CTRL+O) then (CTRL+X) to exit. To execute the multiple website stress test execute the following:
siege -f /etc/siege/urls.txt
Comments and Conclusion
You have learnt how to install the HTTP benchmarking tool Siege for Ubuntu 20.04 successfully. This tool is handy to see what your servers can handle in a clean, easy to understand terminology and settings. Be careful, as we warned at the start of this guide, which should only be used on sites you are authorised to use.