性能测试之 wrk

# 安装 make 工具

sudo apt-get install make

# 安装 gcc编译环境

sudo apt-get install build-essential

git clone https://github.com/wg/wrk

cd /wrk目录

make

linux

root@chaitin-safeline:~/wrk# ./wrk -c 1000 -d 30 -t 32http://1.1.1.252

mac

cd wrk-master

wrk -c 100 -d 30 -t 5http://1.1.1.2

# 使用方法: wrk <选项><被测HTTP服务的URL>  Options:                                           

    -c, --connections   跟服务器建立并保持的TCP连接数量 

    -d, --duration      压测时间(s)         

    -t, --threads      使用多少个线程进行压测(根据 cpu 几核)

    -s, --script        指定Lua脚本路径     

    -H, --header        为每一个HTTP请求添加HTTP头     

        --latency          在压测结束后,打印延迟统计信息 

        --timeout      超时时间   

    -v, --version          打印正在使用的wrk的详细版本信息

  代表数字参数,支持国际单位 (1k, 1M, 1G)

  代表时间参数,支持时间单位 (2s, 2m, 2h)

例如:

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

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个请求)(QPS、最大请求数、最大连接数)Transfer/sec:    22.79MB (平均每秒读取数据22.79MB)(最大吞吐)

-H "Connection: Close"

请求后连接关闭,所以一个连接只有一个请求

如果是keep-alive,一个连接可以有多个请求

标准差如果太大说明样本本身离散程度比较高. 有可能系统性能波动很大

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

-t 一般根据 cpu 数量来定,一般是 cpu 的整数倍

-c 一般是一个线程 100 个

-t 1 -c 100  Requests/sec 为 cps(每秒连接数)

-t 12 -c 1200 Requests/sec 为 qps(四核)

你可能感兴趣的:(性能测试之 wrk)