Installing WRK
Download the source from GitHub first
git clone https://github.com/wg/wrk
Then CD to wrk directory, make install
make
You can then use it directly, and then create a soft connection/usr/local/bin/wrk-/usr/local/src/wrk/wrk in the executable directory.
Basic use of WRK
Let's take a look at Wrk's help.
WRK--helpusage:wrk <options> <url> options:??-c,--connections <N> connections to keep open #跟服务器建 and maintain the number of TCP connections, set the number of voltage measurement concurrent connections??-D,--duration? <T> Duration of test? # #压测时间??-T,--threads? <N> number of threads to use? # #指定压测的线程数??-S,--script?? <S> Load Lua script File # #可指定Lua脚本进行http压测, do you want to study it in detail??-H,--header?? <H> ADD header to request? # #为每一个HTTP请求添加HTTP头,??? How to add it????--latency???? Print Latency Statistics # #打印出延时分布的概率: Latency distribution??????????????????????????????????????????????????? 50%??????????????????????????????????????????? .23ms???????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????? 99% <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)
<N> denotes numerical parameters, supporting international units (1k, 1M, 1G)
<T> indicates time parameter, support time unit (2s, 2m, 2h)
View the WRK version to discover WRK using the epoll mechanism
wrk -vwrk 4.1.0 [epoll] Copyright (C) 2012 Will Glozer
Measuring an intranet HTTP service
Set 5 thread 1000 connection tests and output response delay information in the test results
wrk -c1000 -t5 http://192.168.0.105:80 --latency --timeout 1sRunning 10s test @ http://192.168.0.105:80? 5 threads and 1000 connections? Thread Stats? Avg? ? ? Stdev? ? Max? +/- Stdev? ? Latency? ? 26.28ms? 84.56ms 839.47ms? 91.76%? ? (延迟时间)? ? Req/Sec? ? 7.52k? ? 3.56k? 30.09k? ? 76.06%? ? (每秒处理的请求数)? Latency Distribution? ? 50%? ? 1.31ms? (50%请求子啊1.31ms返回)? ? 75%? ? 2.63ms? (75%请求子啊2.63ms返回)? ? 90%? 51.78ms (90%请求子啊51.78ms返回)? ? 99%? 407.39ms(99%请求子啊407.39ms返回)? 369586 requests in 10.03s, 299.23MB read (10.03s内处理369586个请求,读取684.08MB数据)? Socket errors: connect 0, read 19, write 0, timeout 139(请求异常数量)Requests/sec:? 36858.65 (平均每秒处理完成请求数)Transfer/sec:? ? 29.84MB (平均每秒传输数据大小)
WRK can test simple get requests with a simple command line, but to test more complex HTTP services such as put and post, you can also customize the pressure measurement process with Lua scripting and add it later.
HTTP pressure measurement tool wrk using notes