wrk
Benchmark HTTP servers with multiple threads
TLDR
Run a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open
Run a benchmark with a custom header
Run a benchmark with a request timeout of 2 seconds
SYNOPSIS
wrk [options]
PARAMETERS
-c, --connections
Number of HTTP connections to keep open.
-d, --duration
Duration of the test, e.g. 2s, 2m, 2h
-t, --threads
Number of threads to use.
-s, --script
Lua script to run. See SCRIPTING section.
-H, --header
Add header to each request, e.g. 'User-Agent: wrk'.
-v, --version
Show version details
-b, --latency
Measure latency
--timeout
Socket/request timeout
DESCRIPTION
wrk is a modern HTTP benchmarking tool capable of generating significant load to test web applications and services. It utilizes a multithreaded design and event notification system to perform efficiently. It is primarily designed for developers to evaluate the performance of their HTTP servers, APIs, and other web-based systems.
Unlike simpler tools, wrk simulates real-world traffic patterns by supporting keep-alive connections, pipelining, and configurable timeouts. The tests are configurable to change duration and parallelism to simulate user behavior and perform stress tests. The results include statistics like requests/second, latency distributions, and errors to help identify bottlenecks and optimize system performance.
CAVEATS
wrk relies on system resources such as file descriptors and network ports. High connection counts might require adjusting system limits (ulimit).
SCRIPTING
wrk allows executing Lua scripts, which provide an advanced configuration option. You can modify request structure, add request headers, and process the results.
Some functions available are: wrk.headers, wrk.body, and wrk.method. Also you can define setup and done functions to initialize and close the scripts.
It gives the user the ability to perform very specific and complex tests.
HISTORY
wrk was created by Will Glozer and has gained popularity due to its performance and flexibility. It addresses the limitations of older tools like ab by utilizing asynchronous I/O and multithreading for increased throughput.
It is written in C for performance and features a Lua scripting engine for advanced test customization. Its Lua support makes it versatile and allows for testing different application architectures.