wrk压测的git地址:https://github.com/wg/wrk
wrk安装:直接下载然后解压之后进入目录然后make编译即可。
get请求:
./wrk -t1 -c400 -d200s http://www.baidu.com
参数
-t代表线程数
-c代表连接数
-d代表请求持续时间
发送post请求时需要编写一个lua文件
wrk.method = "POST"
wrk.body = '{"pushtoken":"fl9Hs_5Vs","params":{"dpi":320,"device_category":"phone"}}'
wrk.headers["Content-Type"] = "application/json"
post请求:
./wrk -t1 -c400 -d200s --script=http_post.lua http://www.baidu.com