wrk 网络测试工具的基本使用

364 阅读1分钟

安装

安装:


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



cd wrk

make //编译



cp wrk /usr/local/sbin/ //放到自己的目录下

界面


lst202002020316@ubuntu:~/wrk$ wrk

Usage: wrk <options> <url>

Options:

-c, --connections <N> Connections to keep open

-d, --duration <T> Duration of test

-t, --threads <N> Number of threads to use

-s, --script <S> Load Lua script file

-H, --header <H> Add header to request

--latency Print latency statistics

--timeout <T> Socket/request timeout

-v, --version Print version details

Numeric arguments may include a SI unit (1k, 1M, 1G)

Time arguments may include a time unit (2s, 2m, 2h)

参数说明


Options:

-c, --connections <N> Connections to keep open // 和服务器建立连接并保持的 TCP 连接数量

-d, --duration <T> Duration of test // 具体的压测时间

-t, --threads <N> Number of threads to use // 使用的线程数量

-s, --script <S> Load Lua script file // 加载 lua 文件

-H, --header <H> Add header to request // 添加请求头

--latency Print latency statistics // 打印延迟统计数据

--timeout <T> Socket/request timeout // 超时时间

-v, --version Print version details // 版本信息

实操

  • 200个链接

  • 8个线程

  • 测试 20 s

  • 打印延迟统计数据

wrk -c200 -t8 -d20 --latency https://www.keyy.top/

image.png

数据说明:

  • Latency 延迟

  • Avg 平均值

  • Stdev 标准差

  • +/- Stdev 标准差占比

  • Requests/sec 平均每秒处理的请求数,通常说的 qps 这里可以看出