Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsApr 26, 2026·3 min de lectura

wrk — Modern HTTP Benchmarking Tool

High-performance HTTP benchmarking tool built in C with Lua scripting support for generating significant load on web servers.

Introduction

wrk is a modern HTTP benchmarking tool written in C that can generate significant load using a single multi-core machine. It combines an event-driven architecture with OS-specific optimizations like epoll and kqueue to push far more requests than traditional tools like ApacheBench. When you need to understand how your server handles real concurrency, wrk delivers accurate latency distributions without bottlenecking on the client side.

What wrk Does

  • Generates high-throughput HTTP/HTTPS load with minimal CPU overhead on the client
  • Measures latency distribution including average, standard deviation, max, and percentiles
  • Supports custom HTTP methods, headers, and bodies via embedded Lua scripts
  • Uses a multi-threaded, event-loop architecture to maximize connection throughput
  • Reports requests per second, transfer rates, and socket-level error counts

Architecture Overview

wrk runs one event loop per thread, each managing a share of the total connections. Sockets are handled via non-blocking I/O using epoll on Linux and kqueue on macOS/BSD. An embedded LuaJIT runtime lets users define request generation, response processing, and final reporting callbacks without recompiling. This design keeps the client lightweight while sustaining hundreds of thousands of requests per second from a single machine.

Self-Hosting & Configuration

  • Build from source: git clone https://github.com/wg/wrk && cd wrk && make
  • Install via Homebrew on macOS: brew install wrk
  • Tune threads (-t) to match available CPU cores for optimal throughput
  • Adjust connections (-c) to simulate realistic concurrent user counts
  • Write Lua scripts placed in a scripts/ directory for POST bodies, auth headers, or dynamic URLs

Key Features

  • Achieves millions of requests per second on commodity hardware
  • Embedded LuaJIT scripting for fully customizable request generation
  • Accurate latency histograms with percentile breakdowns
  • Minimal dependencies — compiles to a single static binary on most Unix systems
  • Efficient memory usage even with thousands of concurrent connections

Comparison with Similar Tools

  • ApacheBench (ab) — single-threaded and limited to basic GET/POST; wrk scales across cores
  • hey — simpler Go-based tool with easier installation but no scripting support
  • bombardier — Go-based with a nice progress bar, but lacks Lua-level request customization
  • k6 — full-featured load testing with JavaScript scripting but heavier resource footprint
  • Vegeta — constant-rate attack model in Go; wrk uses open-model concurrency instead

FAQ

Q: Does wrk support HTTP/2? A: No. wrk targets HTTP/1.1 only. For HTTP/2 benchmarking, consider h2load or k6.

Q: How do I send POST requests with wrk? A: Write a Lua script that sets wrk.method and wrk.body in the request() callback, then pass it with -s script.lua.

Q: Can wrk run on Windows? A: Not natively. wrk relies on Unix-specific I/O primitives (epoll/kqueue). Use WSL or a Linux container on Windows.

Q: How many threads should I use? A: Start with the number of physical CPU cores. Adding more threads than cores increases context-switching overhead without improving throughput.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados