下面由golang教程栏目给大家介绍go语言 命令行压力测试工具wrk,希望对需要的朋友有所帮助!
Go语言 命令行压力测试工具Wrk
下载
git clone https://github.com/wg/wrkmakesudo cp -R wrk /usr/local/bin/wrk
查看版本号
wrk -v
使用方法: wrk <选项> <被测HTTP服务的URL>
Options:
-c, --connections 跟服务器建立并保持的TCP连接数量
-d, --duration 压测时间
-t, --threads 使用多少个线程进行压测
-s, --script 指定Lua脚本路径
-H, --header 为每一个HTTP请求添加HTTP头
--latency 在压测结束后,打印延迟统计信息
--timeout 超时时间
-v, --version 打印正在使用的wrk的详细版本信息
代表数字参数,支持国际单位 (1k, 1M, 1G)
代表时间参数,支持时间单位 (2s, 2m, 2h) 常用请求方式
立即学习“go语言免费学习笔记(深入)”;
wrk -t8 -c200 -d30s --latency "http://www.bing.com"
自定义请求 -s
wrk = {
scheme = "http",
host = "localhost",
port = nil,
method = "GET",
path = "/",
headers = {},
body = nil,
thread =
} 列子 先用postman测试之后 直接从post里面copy出来设置
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










