Home >Backend Development >Golang >About the Go language command line stress testing tool Wrk

About the Go language command line stress testing tool Wrk

藏色散人
藏色散人forward
2021-06-01 15:06:462874browse

The following tutorial column will introduce you to the Go language command line stress testing tool Wrk. I hope it will be helpful to friends in need! Go language command line stress testing tool Wrk

Download

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

make

sudo cp -R wrk /usr/local/bin/wrk

View version number

wrk -v
使用方法: wrk <选项> <被测HTTP服务的URL>                            
  Options:                                            
    -c, --connections <N>  跟服务器建立并保持的TCP连接数量  
    -d, --duration    <T>  压测时间           
    -t, --threads     <N>  使用多少个线程进行压测   
                                                      
    -s, --script      <S>  指定Lua脚本路径       
    -H, --header      <H>  为每一个HTTP请求添加HTTP头      
        --latency          在压测结束后,打印延迟统计信息   
        --timeout     <T>  超时时间     
    -v, --version          打印正在使用的wrk的详细版本信息
                                                      
  <N>代表数字参数,支持国际单位 (1k, 1M, 1G)
  <T>代表时间参数,支持时间单位 (2s, 2m, 2h)

Common request methods

wrk -t8 -c200 -d30s --latency "http://www.bing.com"

Custom request-s

wrk = {
    scheme  = "http",
    host    = "localhost",
    port    = nil,
    method  = "GET",
    path    = "/",
    headers = {},
    body    = nil,
    thread  = <userdata>
}
Liezi first use postman to test and then copy and set it directly from the post
wrk.method = "POST"
wrk.body   = "foo=bar&baz=quux"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"

wrk -d3s -c2 -s scripts/post.lua https://httpbin.org/get

The above is the detailed content of About the Go language command line stress testing tool Wrk. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete