借助wrk进行压测的demo

12 阅读1分钟

借助wrk压测命令获取结果集:

借助wrk压测 post 接口

wrk -t1 -c10 -d300s --latency --timeout 5s -s wrk.lua 'http://127.0.0.1:8080/ads'
  • -t 线程数
  • -c 连接数
  • -d 持续时间
  • --latency 延迟
  • --timeout 超时时间
  • -s lua脚本内容
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"
function request()
  body = string.format('{"request_id":"test","api_version":"1.0.0"')
  return wrk.format('POST', nil, nil, body)
end
 
function response(status,headers,body)
                print(body)
end
  • method 填写方法类型[get,post]
  • function request ----》 编写请求内容
  • function response ----》 处理响应内容