Load Testing Best Practices: Insights from the wrk Tool

wrk load testing tool benchmarking HTTP server performance

wrk is a powerful tool used for performance and load testing, specifically designed for evaluating the performance of web servers that support HTTP and HTTPS. It sends requests to a target server under a specified load and measures response times, request counts, and other performance metrics to analyze overall performance.

Info: wrk is highly efficient because it uses event-driven, asynchronous I/O — allowing it to generate far more load than traditional benchmarking tools like ApacheBench (ab).

Key Features of wrk

  1. High Performance: wrk can send a large volume of HTTP requests rapidly, making it ideal for simulating real-world traffic conditions.
  2. Flexible Configuration: Users can customize the load test by specifying connections, request rate, duration, and request content.
  3. Quick Installation: wrk is easy to install and typically runs from the command line.
  4. Advanced Metrics: wrk can record metrics such as time per request, transfer rate, and latency statistics.

Its flexibility makes wrk a preferred choice for developers and system administrators who want to understand and optimize server and application performance.

Tip: wrk can easily saturate network or CPU resources. Always monitor system metrics while testing.

Installation

To install wrk, the process is straightforward and performed through the command line interface.

Linux (Ubuntu)

  1. Open the terminal and run:
    sudo apt-get update 
    sudo apt-get install wrk

macOS

  1. Use Homebrew:
    brew install wrk

Windows

  1. To use wrk on Windows, you may need WSL (Windows Subsystem for Linux). Steps:
Warning: wrk does NOT run natively on Windows without WSL or a Unix-like environment.

Verify Installation

wrk --version

Basic wrk Command

wrk -t12 -c400 -d30s http://example.com
  • -t: Number of threads (virtual users)
  • -c: Number of connections
  • -d: Duration of the test
Tip: Increasing threads does NOT always increase performance. The bottleneck may be CPU, network, or the application itself.

Advanced Options

  • Custom Request (Lua):
    wrk -t12 -c400 -d30s -s script.lua http://example.com

    Use a Lua script to define custom HTTP requests.

  • HTTP Headers:
    wrk -t12 -c400 -d30s --header "Authorization: Bearer token" http://example.com

    Add custom HTTP headers.

  • Connection Timeout:
    wrk -t12 -c400 -d30s --timeout 5s http://example.com

    Set maximum connection wait time.

  • Latency Stats:
    wrk -t12 -c400 -d30s --latency http://example.com

    Shows detailed latency breakdown.

  • Logging Output:
    wrk -t12 -c400 -d30s -L http://example.com

    Useful for gnuplot processing.

Lua Script Example

wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json" 
wrk.body = '{"key": "value"}'

Result Analysis

  • Requests per Second (RPS) – number of processed requests
  • Latency – response time per request
  • Throughput – data transfer rate
  • Concurrency – number of concurrent connections supported
Critical: High RPS does NOT always mean better performance. If latency spikes or errors increase, the server is overloaded.

10Gbps vs 1Gbps: Why Network Speed Matters in Load Testing

One of the most common mistakes when interpreting wrk results is assuming that the server or application is the bottleneck, while in reality the limitation may simply be the network bandwidth.

Info: If you’re testing from a 1Gbps connection, your maximum theoretical throughput is already capped — even if the server could handle more.

For example:

  • 1Gbps network → ~125 MB/s max transfer
  • 10Gbps network → ~1,250 MB/s max transfer

This means:

  • a powerful server may appear slow on a 1Gbps test machine
  • latency and RPS may flatten due to bandwidth saturation
  • results may not reflect real server performance
Warning: If your client-side network is limited, upgrading the server will NOT improve load test results.

For accurate benchmarking, always ensure the testing environment supports the expected throughput. This is where high-speed infrastructure such as a 10Gbps dedicated server becomes critical.

Tip: If you want to validate real network performance, you can use our Looking Glass Complete Guide to run route, latency, and bandwidth tests from multiple locations.

Examples

  • Increased Thread Count:
    wrk -t24 -c800 -d30s http://example.com

    Test with 24 threads and 800 connections.

  • Longer Duration:
    wrk -t12 -c400 -d60s http://example.com

    Test for 60 seconds instead of 30.

Note: Always adjust parameters based on your application and server characteristics.

For more details, see the wrk GitHub Repository.

If your goal is to benchmark high-traffic environments realistically, consider using a testing setup with a 10Gbps dedicated server to avoid artificial bottlenecks.

FAQ

What is wrk used for?

wrk is a high-performance HTTP benchmarking tool used to measure web server throughput, latency, and concurrency under load.

Is wrk better than ApacheBench?

Yes. wrk can generate significantly more load thanks to its event-driven architecture, making it more suitable for modern high-traffic environments.

Can I run wrk on Windows?

wrk does not run natively on Windows. You need WSL or a Unix-like environment.

Why does bandwidth affect wrk results?

If your testing machine has limited bandwidth, it can become the bottleneck and prevent accurate performance measurement.

You May Also Like