Using wrk for HTTP Benchmarking on Windows with WSL

Published

Wrk is a powerful HTTP benchmarking tool.

Unfortunately, it does not support Windows OS.

However, we can use WSL (Windows Subsystem for Linux) to run wrk on Windows machine.

You can follow the official guide on how to install WSL.

Open WSL terminal and run the following commands -

sudo apt-get update
sudo apt-get install build-essential libssl-dev unzip git
git clone https://github.com/wg/wrk.git
cd wrk
make
sudo cp wrk /usr/local/bin

Test the installation by running the command wrk.

If you are running your app in Windows on localhost (or 127.0.0.1) it will not be available in the WSL. You have to bind it on 0.0.0.0. It means the server will accept incoming connections from any IP address assigned to the machine.

For example, if you are using Laravel you can use the following command to host your app -

php artisan serve --host=0.0.0.0 --port=8000

To access this inside WSL, use the system’s local IP address. You can find you local IP using the following command -

ipconfig

Look for the IPv4 Address in the output, which will be something like 192.168.0.103.

Now inside WSL, run the following command to start benchmarking -

wrk -t10 -c100 -d1m http://192.168.0.103:8000

The above command will run the benchmark on 10 threads (-t10) with 100 connections/thread (-c100) for the duration of 1 minute (-d1m). You will see the output like -

Running 1m test @ http://192.168.0.103:8000
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    56.25ms   55.66ms 714.16ms   90.72%
    Req/Sec   219.32    115.31   750.00     65.53%
  128562 requests in 1.00m, 19.86MB read
Requests/sec:   2140.40
Transfer/sec:    338.62KB