← 返回命令列表

Linux command

wrk 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Benchmark a URL

wrk [http://localhost:8080/]

Benchmark with threads, connections, and duration

wrk -t [12] -c [400] -d [30s] [http://localhost:8080/]

Show detailed latency statistics

wrk -t [4] -c [100] -d [10s] --latency [http://localhost:8080/]

Add custom headers

wrk -H "Authorization: Bearer [token]" [http://localhost:8080/]

Use a Lua script

wrk -s [script.lua] [http://localhost:8080/]

Set request timeout

wrk -t [4] -c [100] --timeout [5s] [http://localhost:8080/]

说明

wrk is a modern HTTP benchmarking tool capable of generating significant load using a single multi-core CPU. It combines a multithreaded design with scalable event notification systems (epoll on Linux, kqueue on BSD/macOS). The tool measures requests per second, transfer rate, and latency distribution. It supports HTTP/1.1 with keep-alive connections and optional LuaJIT scripting for custom request generation, response processing, and reporting. Lua scripts enable POST requests, dynamic payloads, custom headers per request, and response validation.

参数

-t, --threads _n_
Number of threads to use.
-c, --connections _n_
Number of HTTP connections to keep open.
-d, --duration _time_
Duration of the test (e.g., 30s, 1m, 2h).
-s, --script _file_
Load a Lua script for custom behavior.
-H, --header _header_
Add a custom HTTP header (repeatable).
-L, --latency
Print detailed latency statistics.
--timeout _time_
Socket/request timeout duration.
-v, --version
Print version information.

FAQ

What is the wrk command used for?

wrk is a modern HTTP benchmarking tool capable of generating significant load using a single multi-core CPU. It combines a multithreaded design with scalable event notification systems (epoll on Linux, kqueue on BSD/macOS). The tool measures requests per second, transfer rate, and latency distribution. It supports HTTP/1.1 with keep-alive connections and optional LuaJIT scripting for custom request generation, response processing, and reporting. Lua scripts enable POST requests, dynamic payloads, custom headers per request, and response validation.

How do I run a basic wrk example?

Run `wrk [http://localhost:8080/]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -t, --threads _n_ do in wrk?

Number of threads to use.