github位址:https://github.com/wg/wrk
一、安裝
Ubuntu/Debian
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev git -y
$ git clone https://github.com/wg/wrk.git wrk
$ cd wrk
$ sudo make
//move the executable to somewhere in your PATH, ex:
$ sudo cp wrk /usr/local/bin
CentOS / RedHat / Fedora
$ sudo yum groupinstall'Development Tools'
$ sudo yum install openssl-devel
$ sudo yum install gitgit clone https://github.com/wg/wrk.git wrk
$ cd wrk
$ make
//move the executable to somewhere in your PATH
$ sudo cp wrk /somewhere/in/your/PATH
其他系統參考:https://github.com/wg/wrk/wiki
二、使用
wrk的使用非常簡單
一行指令搞定
$ wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
// 運作30s,開啟12線程,總共保持400個HTTP連接配接開啟
三、wrk報告
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
結果也不難了解。
latency那一行反映了請求響應時間,分别為平均值,标準差,最大值,正負一個标準差内的比例;
transfer為資料交換量。
其他都很好了解,無須解釋了。