安装rpm包
rpm -ivh wrk-4.1.0-1.el7.centos.x86_64.rpm
使用示例
wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
输出解释
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 # 每秒传输的数据量
命令行选项
-c, --connections: 连接数 相当于多少个用户并发访问
each thread handling N = connections/threads
-d, --duration: 压测持续时间, e.g. 2s, 2m, 2h
-t, --threads: 使用的线程数,此参数选项和CPU内核数量有关,一般与CPU核数相等
-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.