Need to stress-test your websites to see how well they’re performing? Jack Wallen shows you how with the command-line Siege tool.

open-source-linux-code.jpg
Image: iStock

If you’re a web admin, one of your constant challenges is optimizing sites so they perform their best. After all, a slow website could easily turn off clients and customers. To optimize those sites, you might want to first benchmark them to know how well (or poorly) they perform.

SEE: Hiring Kit: JavaScript Developer (TechRepublic Premium)

One tool to help you benchmark your websites is the command-line application, Siege. Siege performs web server load testing and gives you complete details for:

  • The number of hits recorded
  • Amount of bytes transferred
  • Response time
  • Concurrency
  • Return status

Siege also supports both the HTTP/1.0 and 1.1 protocols, the GET and POST directives, cookies, transaction logging and basic authentication.

Let’s get Siege installed on Pop!_OS Linux and stress test a website.

What you’ll need

The only things you’ll need to follow along are a Ubuntu-based distribution, a user with sudo privileges and a website to test.

That’s it. Let’s make some noise.

How to install Siege

Siege is found in the standard Ubuntu repositories, so all you have to do is open a terminal window and issue the command:

sudo apt-get install siege -y

After installation, let’s enable logging. To do that, open the configuration file with:

sudo nano /etc/siege/siegerc

In that file, look for the line:

#logfile = $(HOME)/var/log/siege.log

Change that line to:

logfile = $(HOME)/var/log/siege.log

Save and close the file.

How to perform a stress test

What we’re going to do is run a 5-minute stress test and increase the concurrent user load from the default of 25 to 100. This is done with the command:

siege https://SERVER -c 100 -t 5m

Where SERVER is either the IP address or domain of the server to be tested. Once the five-minute test is up, Siege will report its findings in both the terminal (Figure A) and the log file.

Figure A

Siege has completed testing a site on my local LAN.
Siege has completed testing a site on my local LAN.

If you want to have Siege generate a log file for the test, you would have to run it like so:

siege https://SERVER -c 100 -t 5m -l

Where SERVER is either the IP address or domain of the server to be tested. Also, if you find Siege showing errors about not being able to write to the default log file (and it’s showing /var/log/log/siege.log as the file), you’ll need to edit a different configuration file with the command:

nano ~/.siege/siege.conf

In that file, uncomment the log file line and you should be good to go with logs.

How to test multiple sites at once

Let’s say you have numerous sites you want to test at once. To do that we’ll create a file with a list of sites. Create the file with:

nano ~/siege-sites.txt

In that file, add each site, one line at a time like so:

www.example.org

192.168.1.151

Save and close the file. You can then run Siege against those sites with:

siege -f ~/siege-sites.txt

Siege will then run the default test against all sites included in the txt file.

And that’s all there is to stress-testing your websites with the Siege command-line tool. Use the results to help you find ways to improve the performance of the sites you administer.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.



Source link