wrk压测工具

安装

cd /opt
git clone https://github.com/wg/wrk.git
cd wrk
make
ln -s /opt/wrk/wrk /usr/local/bin

Git下载慢的话可以使用加速链接 https://github.com.cnpmjs.org/wg/wrk.git

使用说明

[root@localhost opt]# wrk
Usage: wrk <options> <url>                            
Options:                                            
  -c, --connections <N> Connections to keep open  
  -d, --duration   <T> Duration of test          
  -t, --threads     <N> Number of threads to use  

  -s, --script     <S> Load Lua script file      
  -H, --header     <H> Add header to request      
      --latency         Print latency statistics  
      --timeout     <T> Socket/request timeout    
  -v, --version         Print version details      

Numeric arguments may include a SI unit (1k, 1M, 1G)
Time arguments may include a time unit (2s, 2m, 2h)

示例:

[root@localhost ~]# wrk -t 8 -c 500 -d 30 --latency http://192.168.11.5:8000/client/1
Running 30s test @ http://192.168.11.5:8000/client/1
  8 threads and 500 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   751.06ms  526.96ms   1.95s    59.53%
    Req/Sec   112.46    107.55   650.00     78.82%
  Latency Distribution
     50%  848.00ms
     75%  934.46ms
     90%    1.65s 
     99%    1.82s 
  17120 requests in 30.09s, 8.72MB read
  Socket errors: connect 0, read 0, write 0, timeout 860
Requests/sec:    568.93
Transfer/sec:    296.69KB