wrk基本使用

介绍


wrk是一个现代的HTTP基准测试工具,当在单个多核CPU上运行时能够产生大量负载。

支持Lua脚本,能够执行HTTP请求生成、响应处理和自定义报告执行结果


安装


Mac

可能会报错,报错就下载源码手动编译

brew install wrk
Linux
sudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
cd wrk
sudo make
# move the executable to somewhere in your PATH, ex:
sudo cp wrk /usr/local/bin

或者从releases中下载:

https://github.com/wg/wrk/releases/tag/4.2.0

在这里插入图片描述



基本用法


wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

以上命令表示:运行一个持续时长为30秒,使用12个线程,保持打开400个HTTP连接的压测。

输出:

Running 30s test @ http://127.0.0.1:8080/index.html
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   635.91us    0.89ms  12.92ms   93.69%
    Req/Sec    56.20k     8.07k   62.00k    86.54%
  22464657 requests in 30.00s, 17.76GB read
Requests/sec: 748868.53 // 表示每秒的请求数
Transfer/sec:    606.33MB

命令行选项


-c, --connections(连接数): total number of HTTP connections to keep open with
                   each thread handling N = connections/threads

-d, --duration(持续时间):    duration of the test, e.g. 2s, 2m, 2h

-t, --threads(线程数):     total number of threads to use

-s, --script(指定Lua脚本):      LuaJIT script, see SCRIPTING

-H, --header(指定请求头):      HTTP header to add to request, e.g. "User-Agent: wrk"

    --latency(打印延迟统计信息):     print detailed latency statistics

    --timeout(打印响应超时信息):     record a timeout if a response is not received within
                   this amount of time.

参考链接

  • https://github.com/wg/wrk
  • https://medium.com/@felipedutratine/intelligent-benchmark-with-wrk-163986c1587f
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值