wrk是一款現(xiàn)代HTTP基準測試工具,能夠在單個多核CPU上運行時產生顯著負載。它將多線程設計與可擴展事件通知系統(tǒng)(如epoll和kqueue)結合在一起。
基本用法
使用12個線程運行30秒的基準測試,并保持400個HTTP連接處于打開狀態(tài)
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
測試Swoole對laravel5.5的加速個例
brew install wrk // 沒有命令需安裝
wrk -t4 -c100 http://live.com or http://127.0.0.1:9501/
帶有FPM的Nginx
Running 10s test @ http://live.com
4 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.14s 191.03ms 1.40s 90.31%
Req/Sec 22.65 10.65 50.00 65.31%
815 requests in 10.07s, 223.65KB read
Requests/sec: 80.93
Transfer/sec: 22.21KB
Swoole HTTP服務器
Running 10s test @ http://127.0.0.1:9501
4 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 11.58ms 4.74ms 68.73ms 81.63%
Req/Sec 2.19k 357.43 2.90k 69.50%
87879 requests in 10.08s, 15.67MB read
Requests/sec: 8717.00
Transfer/sec: 1.55MB