wrk HTTP Benchmarking Tool

repository·master·Indexed 13 days ago

https://github.com/wg/wrk

A modern, high-performance HTTP benchmarking tool designed for generating significant load on multi-core CPUs using a multithreaded design and scalable event notification systems like epoll and kqueue. Supports custom request generation and response processing via LuaJIT scripts.

Tokens
718
Snippets
2
Records
4
Agent score
49%

What's inside wrk

  1. How to interpret wrk output

    master

    The output provides a summary of the benchmark results, including:

    • Thread Stats: Average, standard deviation, and maximum values for Latency and Requests per second (Req/Sec).
    • Summary Line: Total requests made, duration, and total data read.
    • Requests/sec: The overall throughput of the benchmark.
    • Transfer/sec: The overall data transfer rate.
    Running 30s test @ http://127.0.0.1:8080/index.html
      12 threads and 400 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   635.91us    0.89ms  12.92ms   93.69%
        Req/Sec    56.20k     8.07k   62.00k    86.54%
      22464657 requests in 30.00s, 17.76GB read
    Requests/sec: 748868.53
    Transfer/sec:    606.33MB
  2. Benchmarking Tips for high-load testing

    master

    To achieve maximum load and accurate results, consider the following:

    System Configuration

    • Ephemeral Ports: Ensure the machine running wrk has a sufficient number of ephemeral ports available.
    • Socket Recycling: Ensure closed sockets are recycled quickly by the OS.
    • Server Backlog: To handle the initial connection burst, the server's listen(2) backlog should be greater than the number of concurrent connections being tested.

    Scripting Performance

    • Low Impact: Using a LuaJIT script to only change the HTTP method, path, headers, or body has negligible performance impact.
    • High Impact: Per-request actions, specifically building a new HTTP request from scratch or using the response() function, will reduce the total amount of load wrk can generate.
  3. Run a basic HTTP benchmark with wrk

    master

    To perform a standard HTTP benchmark, provide the target URL and use flags to specify the number of threads, connections, and duration.

    Example: Running a benchmark for 30 seconds using 12 threads and 400 concurrent connections.

    wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
  4. Command Line Options for wrk

    master

    Use the following flags to configure your benchmark execution:

    • -c, --connections: Total number of HTTP connections to keep open. Each thread handles N = connections/threads connections.
    • -d, --duration: Duration of the test (e.g., 2s, 2m, 2h).
    • -t, --threads: Total number of threads to use.
    • -s, --script: Path to a LuaJIT script for custom request generation or response processing.
    • -H, --header: HTTP header to add to the request (e.g., "User-Agent: wrk").
    • --latency: Print detailed latency statistics in the output.
    • --timeout: Record a timeout if a response is not received within the specified amount of time.