Convert Figma logo to code with AI

wg logowrk

Modern HTTP benchmarking tool

37,830
2,938
37,830
196

Top Related Projects

18,056

HTTP load generator, ApacheBench (ab) replacement

23,459

HTTP load testing tool and library. It's over 9000!

24,772

Write scalable load tests in plain Python 🚗💨

4,261

A constant throughput, correct latency recording variant of wrk

Fast cross-platform HTTP benchmarking tool written in Go

Quick Overview

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue to efficiently manage thousands of connections.

Pros

  • High performance and low resource usage
  • Supports HTTP/HTTPS with optional TLS support
  • Scriptable with Lua for custom request generation and response handling
  • Simple command-line interface for quick benchmarking

Cons

  • Limited to HTTP/HTTPS protocols only
  • Lacks built-in support for more complex scenarios like authentication or session management
  • May require additional setup for TLS support
  • Limited reporting capabilities compared to some more feature-rich benchmarking tools

Code Examples

wrk is a command-line tool, not a code library. Therefore, there are no code examples to provide.

Getting Started

To get started with wrk, follow these steps:

  1. Clone the repository:

    git clone https://github.com/wg/wrk.git
    
  2. Build wrk:

    cd wrk
    make
    
  3. Run a basic benchmark:

    ./wrk -t12 -c400 -d30s http://example.com
    

    This command runs a benchmark using 12 threads and 400 connections for 30 seconds against http://example.com.

  4. For more advanced usage, including Lua scripting, refer to the project's README and documentation.

Competitor Comparisons

18,056

HTTP load generator, ApacheBench (ab) replacement

Pros of hey

  • Written in Go, making it more portable and easier to install across different platforms
  • Supports HTTP/2 out of the box
  • Provides a simpler command-line interface, making it more user-friendly for beginners

Cons of hey

  • Generally slower performance compared to wrk
  • Less customizable and extensible than wrk
  • Limited reporting options and metrics compared to wrk's Lua scripting capabilities

Code Comparison

hey:

func (b *Work) Run() {
    b.results = make(chan *result, b.N)
    b.stopCh = make(chan struct{}, b.C)
    b.start = time.Now()
    b.startTimer()
    b.runWorkers()
}

wrk:

static void *thread_main(void *arg) {
    thread *t = arg;
    aeEventLoop *loop = aeCreateEventLoop(10 + cfg.connections);
    thread_start(loop, t);
    aeMain(loop);
    aeDeleteEventLoop(loop);
    return NULL;
}

Both repositories are HTTP benchmarking tools, but they differ in implementation and features. hey is more modern and user-friendly, while wrk offers better performance and customization options. The code snippets show the core functionality of running workers/threads in each tool, highlighting the different languages and approaches used.

23,459

HTTP load testing tool and library. It's over 9000!

Pros of Vegeta

  • Supports multiple output formats (JSON, CSV, Histogram)
  • Offers more detailed metrics and reporting capabilities
  • Can be used as a library in Go programs for custom load testing scenarios

Cons of Vegeta

  • Generally slower than wrk for high-concurrency scenarios
  • Less efficient for testing very high loads on a single machine
  • Requires more setup and configuration for complex test cases

Code Comparison

Vegeta:

rate := vegeta.Rate{Freq: 100, Per: time.Second}
duration := 5 * time.Second
targeter := vegeta.NewStaticTargeter(vegeta.Target{
    Method: "GET",
    URL:    "http://example.com",
})
attacker := vegeta.NewAttacker()

for res := range attacker.Attack(targeter, rate, duration, "Big Bang!") {
    // Process results
}

wrk:

wrk.method = "GET"
wrk.path   = "/"
wrk.headers["Host"] = "example.com"

function request()
    return wrk.format()
end

function response(status, headers, body)
    -- Process response
end

Both tools are powerful load testing solutions, but Vegeta offers more flexibility and detailed reporting, while wrk excels in raw performance for high-concurrency scenarios. Vegeta's Go-based approach allows for easier integration into existing Go codebases, while wrk's Lua scripting provides a lightweight and fast option for simpler load testing needs.

24,772

Write scalable load tests in plain Python 🚗💨

Pros of Locust

  • Written in Python, making it more accessible and easier to extend for many developers
  • Supports distributed load testing out of the box
  • Provides a web-based UI for real-time monitoring and control of tests

Cons of Locust

  • Generally slower performance compared to wrk due to Python's overhead
  • Requires more setup and configuration for complex scenarios
  • Less suitable for extremely high concurrency tests

Code Comparison

wrk example:

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

Locust example:

@task
def post_request(self):
    self.client.post("/endpoint", json={"foo": "bar"})

Both tools allow customization of requests, but wrk uses Lua scripting while Locust uses Python. Locust's approach is generally more intuitive for those familiar with Python, while wrk's Lua scripting can be more efficient for high-performance scenarios.

Locust is better suited for complex, distributed load testing scenarios with a user-friendly interface, while wrk excels in raw performance and simplicity for high-concurrency benchmarking.

4,261

A constant throughput, correct latency recording variant of wrk

Pros of wrk2

  • Provides accurate latency measurements with coordinated omission compensation
  • Offers more detailed statistical output, including percentiles and histograms
  • Supports constant throughput load testing, allowing for more precise control over test scenarios

Cons of wrk2

  • Generally slower execution compared to wrk due to additional overhead
  • May require more system resources for processing and storing detailed statistics
  • Less frequently updated and maintained compared to the original wrk project

Code Comparison

wrk:

wrk.method = "POST"
wrk.body   = "foo=bar&baz=quux"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"

wrk2:

wrk.method = "POST"
wrk.body   = "foo=bar&baz=quux"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
wrk.headers["X-Custom-Header"] = "wrk2-specific"

The code structure is similar, with wrk2 allowing for additional customization options and headers. Both projects use Lua for scripting, maintaining compatibility in basic usage scenarios.

Fast cross-platform HTTP benchmarking tool written in Go

Pros of Bombardier

  • Written in Go, making it more portable and easier to install across different platforms
  • Supports HTTP/1.1, TLS, and HTTP/2 protocols
  • Provides more detailed statistics and percentiles in the output

Cons of Bombardier

  • Generally slower performance compared to wrk, especially for high concurrency scenarios
  • Less mature project with fewer contributors and stars on GitHub
  • Limited customization options for complex benchmarking scenarios

Code Comparison

wrk:

wrk.method = "POST"
wrk.body   = "foo=bar&baz=quux"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"

Bombardier:

bombardier -m POST -b "foo=bar&baz=quux" -H "Content-Type: application/x-www-form-urlencoded" http://example.com

Both tools allow setting HTTP methods, request bodies, and headers. wrk uses a Lua script for configuration, while Bombardier uses command-line flags. wrk's approach offers more flexibility for complex scenarios, but Bombardier's command-line interface is simpler for basic use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

wrk - a HTTP benchmarking tool

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue.

An optional LuaJIT script can perform HTTP request generation, response processing, and custom reporting. Details are available in SCRIPTING and several examples are located in scripts/.

Basic Usage

wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

This runs a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open.

Output:

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

Command Line Options

-c, --connections: total number of HTTP connections to keep open with
                   each thread handling N = connections/threads

-d, --duration:    duration of the test, e.g. 2s, 2m, 2h

-t, --threads:     total number of threads to use

-s, --script:      LuaJIT script, see SCRIPTING

-H, --header:      HTTP header to add to request, e.g. "User-Agent: wrk"

    --latency:     print detailed latency statistics

    --timeout:     record a timeout if a response is not received within
                   this amount of time.

Benchmarking Tips

The machine running wrk must have a sufficient number of ephemeral ports available and closed sockets should be recycled quickly. To handle the initial connection burst the server's listen(2) backlog should be greater than the number of concurrent connections being tested.

A user script that only changes the HTTP method, path, adds headers or a body, will have no performance impact. Per-request actions, particularly building a new HTTP request, and use of response() will necessarily reduce the amount of load that can be generated.

Acknowledgements

wrk contains code from a number of open source projects including the 'ae' event loop from redis, the nginx/joyent/node.js 'http-parser', and Mike Pall's LuaJIT. Please consult the NOTICE file for licensing details.

Cryptography Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with symmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.