wrk 使用

  • 目录 {:toc}

what

wrk 的实现使用了多线程和事件机制,使其在一台多核的cpu上也能跑出很好的测试效果。在请求的生成,响应的处理,自定义测试报告的生成的时候,能嵌入lua脚本(luajit)做一些操作,比如,当使用POST传递数据的时候就需要用到lua脚本将数据填入。

usage

可以使用的参数不多,但是足以完成需求。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

$ ./wrk
Usage: wrk <options> <url>
Options:
-c, --connections <N> Connections to keep open
-d, --duration <T> Duration of test
-t, --threads <N> Number of threads to use

-s, --script <S> Load Lua script file
-H, --header <H> Add header to request
--latency Print latency statistics
--timeout <T> Socket/request timeout
-v, --version Print version details

Numeric arguments may include a SI unit (1k, 1M, 1G)
Time arguments may include a time unit (2s, 2m, 2h)
wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

这个例子表示,用12 个线程 保持打开400个连接,持续30s

docker

如果因为各种原因无法编译,可以尝试一下docker 版本的。首先是你的先装个docker,:)。

docker run --rm williamyeh/wrk -t2 -c5 -d5s -H 'Host: example.com' --timeout 2s http://$APP1_PRIVATE_IP:3000/


wrk 使用
http://blog.soul11201.com/2016/12/19/wrk/
作者
soul11201
发布于
2016年12月19日
许可协议