HTTP压测wrk

下载源码编译wrk

git clone https://github.com/wg/wrk.git

直接进目录 make 即可

使用方式

root@ser745692301841:/dev_dir/wrk# ls
CHANGES  INSTALL  LICENSE  Makefile  NOTICE  README.md  SCRIPTING  deps  obj  scripts  src  wrk
root@ser745692301841:/dev_dir/wrk# ./wrk --help
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)

使用样例

wrk -c {{connection_num}} -t {{threads}} http://IP:20023/
wrk -c {{connection_num}} -t {{threads}} -d60s --header "Connection: keep-alive" http://127.0.0.1:20023/