Ironman Software Forums
Continue the conversion on the Ironman Software forums. Chat with over 1000 users about PowerShell, PowerShell Universal, and PowerShell Pro Tools.
In this post, we’ll look at how to benchmark a web application with Siege.
Siege is an HTTP and HTTPS stress testing tool for Linux. It can run web requests using a configurable amount of threads. In benchmark mode, it runs as fast as possible with no delays.
In this blog post, I’m using Ubuntu 20.04 running in WLS2 on a Windows 11 host machine. To install Siege on Ubuntu, run the following commands.
sudo apt update -y
sudo apt install siege -y
siege --version
In order for the Ubuntu image to reach the host machine, you will need to retrieve it from the resolve.conf
file. You can retrieve it using the following command. It will print the IP address directly to terminal.
grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'
172.18.224.1
We typically use Siege to performance test PowerShell Universal so I will be using it in this example.
I have installed the application as a service and it is listening on its default port of 5000. I’ve also created an API endpoint for this test.
New-PSUEndpoint -Url /benchmark -Method GET -Endpoint {
"Hello, world"
}
I can invoke my endpoint locally using PowerShell.
Invoke-RestMethod http://localhost:5000/test
From within my WSL2 environment, I can also invoke the endpoint using wget
. I have to use the IP address of the host machine.
wget htt://172.18.224.1:5000/benchmark
--2022-04-13 07:21:35-- http://172.18.224.1:5000/benchmark
Connecting to 172.18.224.1:5000... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘benchmark’
benchmark [ <=> ] 12 --.-KB/s in 0s
2022-04-13 07:21:35 (1.95 MB/s) - ‘benchmark’ saved [12]
To run Siege in benchmark mode, you will use the -b
flag and pass the URL you’d like to benchmark. By default, it will run with 25 threads.
siege -b http://172.18.224.1:5000/benchmark
I let the benchmark run for sometime and then hit Ctrl+C
to terminate the test. My test ran for 67 seconds with a request rate of about 1000 requests per second.
** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege...
Transactions: 72893 hits
Availability: 100.00 %
Elapsed time: 67.34 secs
Data transferred: 2.64 MB
Response time: 0.02 secs
Transaction rate: 1082.46 trans/sec
Throughput: 0.04 MB/sec
Concurrency: 24.96
Successful transactions: 72893
Failed transactions: 0
Longest transaction: 0.51
Shortest transaction: 0.01
You can also increase the number of concurrent HTTP request threads in Siege by using the -c
parameter.
siege -c 125 -b http://172.18.224.1:5000/benchmark
In this post, we looked at how to benchmark a web application using Siege.
Continue the conversion on the Ironman Software forums. Chat with over 1000 users about PowerShell, PowerShell Universal, and PowerShell Pro Tools.
Receive once-a-month updates about Ironman Software. You'll learn about our product updates and blogs related to PowerShell.