• wrk 压测工具


    安装

    安装命令

    git clone https://github.com/wg/wrk
     ll
    cd wrk/
     ll
     make
     ll
    cp wrk /usr/local/sbin/
    
    • 帮助 wrk
    使用方法: wrk <选项> <被测HTTP服务的URL>                            
      Options:                                            
        -c, --connections <N>  跟服务器建立并保持的TCP连接数量  
        -d, --duration    <T>  压测时间           
        -t, --threads     <N>  使用多少个线程进行压测   
                                                          
        -s, --script      <S>  指定Lua脚本路径       
        -H, --header      <H>  为每一个HTTP请求添加HTTP头      
            --latency          在压测结束后,打印延迟统计信息   
            --timeout     <T>  超时时间     
        -v, --version          打印正在使用的wrk的详细版本信息
                                                          
      <N>代表数字参数,支持国际单位 (1k, 1M, 1G)
      <T>代表时间参数,支持时间单位 (2s, 2m, 2h)
    

    wrk -c1000 -t10 -d10 --latency "http://10.100.48.39:8898/find"

    • 结果显示
    Running 30s test @ http://www.bing.com (压测时间30s)
      8 threads and 200 connections (共8个测试线程,200个连接)
      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 (99分位的延迟)
      1790465 requests in 30.01s, 684.08MB read (30.01秒内共处理完成了1790465个请求,读取了684.08MB数据)
    Requests/sec:  59658.29 (平均每秒处理完成59658.29个请求)
    Transfer/sec:     22.79MB (平均每秒读取数据22.79MB)


    https://www.jianshu.com/p/cead8227ade5

    https://github.com/wg/wrk/blob/master/scripts/post.lua

    https://www.cnblogs.com/jiftle/p/7158291.html

    https://www.cnblogs.com/rainy-shurun/p/5867946.html

    https://zjumty.iteye.com/blog/2221040

    https://www.cnblogs.com/xinzhao/p/6233009.html

    get

    ./wrk -t4 -c4 -d10s --latency --script=get.lua http://10.142.71.237:9999

    wrk.method = "GET"
    wrk.headers["version"] = "1.1.0"
    request = function()
    sku = tostring(math.random(1,99999999));
    level = tostring(math.random(1,99999999));
    path = "/api/c/price/predict?category=5&sku=123759&level=525&brand=103&product=6322"
    return wrk.format(nil, path)
    end

    post

    ./wrk -t2 -c20 -d5s -T30s --latency --script=postdic.lua http://10.142.71.237:9999/api/b/price/predict

    wrk.method = "POST"
    wrk.body = '[{"product":6421,"brand":7,"category":1,"sku":287902,"level":494}]'
    wrk.headers["Content-Type"] = "application/json"
    wrk.headers["version"] = "1.1.0"

  • 相关阅读:
    tensorflow2.0第1章 Tensorflow简介与环境搭建
    SIGAI机器学习第二十四集 聚类算法1
    SIGAI机器学习第二十三集 高斯混合模型与EM算法
    51nod1429 巧克力
    CTSC2018 Day2T1 Juice混合果汁
    CF1B Spreadsheets
    CF2B The least round way
    【模板】点分治
    【模板】AC自动机
    【模板】网络流-最大流 Dinic
  • 原文地址:https://www.cnblogs.com/du-jun/p/11172068.html
Copyright © 2020-2023  润新知