编程笔记

lifelong learning & practice makes perfect

wrk

wrk

  1. usage
    HTTP benchmarking tool.
    More information: https://github.com/wg/wrk.
  2. param
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    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 //lua脚本
    -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)

examples

  1. 测试go-zero demo中的check接口
    1
    wrk -t10 -c1000 -d30s --latency "http://localhost:8888/check?book=go-zero"
  2. 结果
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Running 30s test @ http://localhost:8888/check? book=go-zero
    10 threads and 1000 connections
    Thread Stats Avg Stdev Max +/- Stdev
    Latency 128.84ms 60.10ms 593.00ms 77.53%
    Req/Sec 794.67 304.69 1.95k 69.54%
    Latency Distribution
    50% 115.23ms
    75% 153.24ms
    90% 203.13ms
    99% 339.48ms
    233390 requests in 30.10s, 29.60MB read
    Requests/sec: 7754.33
    Transfer/sec: 0.98MB

ubuntu下使用

  1. 安装
    1
    2
    3
    4
    5
    6
    7
    8
    git clone https://github.com/wg/wrk.git

    // 构建可执行文件
    cd wrk
    make

    // 软连接
    ln -s 绝对路径/wrk /usr/local/bin(任意在PATH中的路径都可以)

欢迎关注我的其它发布渠道