macOS linux 并发测试工具 wrk
wrk https://github.com/wg/wrk
使用 HomeBrew 安装即可
brew install wrk
使用
wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
-c, --connections: total number of HTTP connections to keep open with
each thread handling N = connections/threads
-d, --duration: 持续时间, 例:2s, 2m, 2h
-t, --threads: 线程数
-s, --script: 脚本 LuaJIT script, 参阅 SCRIPTING
-H, --header: 添加 HTTP header 到请求, 例: "User-Agent: wrk"
--latency: print detailed latency statistics
--timeout: 请求未收到响应的超时时间
例如:
https://kylebing.cn@Kyles-MBP go % wrk -t12 -c400 -d5 "http://localhost:9999/diary?id=3&type=query"
Running 5s test @ http://localhost:9999/diary?id=3&type=query
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 151.05ms 114.45ms 866.35ms 81.38%
Req/Sec 138.45 103.84 494.00 66.72%
7992 requests in 5.08s, 2.78MB read
Socket errors: connect 157, read 50, write 0, timeout 0
Non-2xx or 3xx responses: 643
Requests/sec: 1573.68
Transfer/sec: 559.93KB
后台 LOG