安装rpm包

  1. rpm -ivh wrk-4.1.0-1.el7.centos.x86_64.rpm

使用示例

  1. wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

输出解释

  1. Running 30s test @ http://127.0.0.1:8080/index.html
  2. 12 threads and 400 connections
  3. Thread Stats Avg Stdev Max +/- Stdev
  4. Latency 635.91us 0.89ms 12.92ms 93.69%
  5. Req/Sec 56.20k 8.07k 62.00k 86.54%
  6. 22464657 requests in 30.00s, 17.76GB read # 压测时间内完成的请求数与请求到的数据量
  7. Requests/sec: 748868.53 # 每秒处理的请求
  8. Transfer/sec: 606.33MB # 每秒传输的数据量

命令行选项

  1. -c, --connections: 连接数 相当于多少个用户并发访问
  2. each thread handling N = connections/threads
  3. -d, --duration: 压测持续时间, e.g. 2s, 2m, 2h
  4. -t, --threads: 使用的线程数,此参数选项和CPU内核数量有关,一般与CPU核数相等
  5. -s, --script: LuaJIT script, see SCRIPTING
  6. -H, --header: HTTP header to add to request, e.g. "User-Agent: wrk"
  7. --latency: print detailed latency statistics
  8. --timeout: record a timeout if a response is not received within
  9. this amount of time.