wrk README

The project's README from github.com/wg/wrk. As one markdown file: README.md.

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.

wrk (wg/wrk)

Searching Database…

40.4K ·GitHub
这是什么?wrk 是一个现代的 HTTP 压测工具,可以在单台多核机器上对服务器产生大量负载,并测量延迟和吞吐量。
这是图形界面应用还是命令行工具?这是命令行工具,通过 -t、-c、-d 等参数来配置线程数、连接数和持续时间。
我该怎么用它运行压测?先编译,然后运行类似 'wrk -t12 -c400 -d30s http://target' 的命令,指定线程数、连接数和测试时长。
构建和使用它需要预先安装什么?它用 C 语言编写,可选的脚本功能使用 LuaJIT;需要用 make 从源码编译(文中未提及通过包管理器安装)。
运行大规模压测时有哪些需要注意的地方?测试机器需要有足够多的空闲临时端口,并能快速回收套接字;目标服务器的监听队列长度必须大于并发连接数,否则结果会有偏差。
它只能在 Linux 上运行吗?它依赖 epoll(Linux)和 kqueue(BSD/macOS)这类可扩展的事件通知机制,因此两种平台都支持。
我可以自定义它发送的请求吗?可以,用 -s 附加一个 LuaJIT 脚本,就能自定义请求生成、响应处理和报告输出,详见 SCRIPTING 文档以及 scripts/ 目录中的示例。
使用脚本会拖慢压测吗?只修改请求方法、路径、请求头或请求体的简单脚本不会影响性能;但如果每次请求都要构建新请求,或使用 response(),就会降低可达到的负载。
我可以添加自定义请求头或设置超时吗?可以。用 -H 为每个请求添加一个 HTTP 请求头;用 --timeout 设置超时,若在指定时间内没有收到响应则将该请求标记为失败;--latency 会输出详细的延迟统计。
wrk 用到了现有的开源代码吗?用到了。它整合了 redis 的 ae 事件循环、nginx/joyent/node.js 的 http-parser,以及 Mike Pall 的 LuaJIT。
What are similar projects?vegeta, hey, goreplay, locust, bazel, oha, lua-nginx-module, k6
Creator
wg
Size
37.8 MB
Stars
40.4K
Updated
CommitFeb 07
Age
14y
Commits · 90 Days