标签搜索

目 录CONTENT

文章目录
Web

linux压测工具wrk使用

陈铭
2021-07-02 / 0 评论 / 0 点赞 / 244 阅读 / 286 字 / 正在检测是否收录...

安装使用

下载安装

git clone https://github.com/wg/wrk
make # 安装

使用

在源码根目录下./wrk执行

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

案例

使用8个线程200个连接,对bing首页进行了30秒的压测,并要求在压测结果中输出响应延迟信息。

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

输出:
Running 30s test @ http://www.bing.com
  8 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    46.67ms  215.38ms   1.67s    95.59%
    Req/Sec     7.91k     1.15k   10.26k    70.77%
  Latency Distribution
     50%    2.93ms
     75%    3.78ms
     90%    4.73ms
     99%    1.35s 
  1790465 requests in 30.01s, 684.08MB read
Requests/sec:  59658.29
Transfer/sec:     22.79MB
0

评论区