壓力測試

http協議壓力測試 wrk

Posted by Spencer on September 6, 2017

壓力測試 wrk

安裝wrk

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

cd wrk

make

make成功后在目錄內會生成可執行文件

參數列表

-c, --connections: total number of HTTP connections to keep open with
                   each thread handling N = connections/threads

-d, --duration:    duration of the test, e.g. 2s, 2m, 2h

-t, --threads:     total number of threads to use

-s, --script:      LuaJIT script, see SCRIPTING

-H, --header:      HTTP header to add to request, e.g. "User-Agent: wrk"

    --latency:     print detailed latency statistics

    --timeout:     record a timeout if a response is not received within
                   this amount of time.

例子

1、測試baidu, t模擬線程數量 c模擬鏈接數量 d執行時間

 ./wrk -t14 -c50 -d15s http://www.baidu.com
Running 15s test @ http://www.baidu.com
  14 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   139.90ms   85.17ms 939.30ms   89.38%
    Req/Sec    22.52      8.82    60.00     75.30%
  4705 requests in 15.09s, 69.17MB read
  Socket errors: connect 0, read 23, write 0, timeout 0
Requests/sec:    311.88
Transfer/sec:      4.59MB

2、測試baidu, t模擬線程數量 c模擬鏈接數量 d執行時間 T超時時間

./wrk -t14 -c50 -d15s -T30s  http://www.baidu.com
Running 15s test @ http://www.baidu.com
  14 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   134.41ms   84.20ms 855.40ms   89.03%
    Req/Sec    23.48      9.05    60.00     73.66%
  4871 requests in 15.10s, 71.69MB read
  Socket errors: connect 0, read 18, write 0, timeout 0
Requests/sec:    322.63
Transfer/sec:      4.75MB

3、測試baidu, t模擬線程數量 c模擬鏈接數量 d執行時間 T超時時間 latency晌應時間分佈

./wrk -t14 -c50 -d15s -T30s --latency http://www.baidu.com
Running 15s test @ http://www.baidu.com
  14 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   134.75ms   82.65ms   1.19s    89.16%
    Req/Sec    23.57      9.18    89.00     75.41%
  Latency Distribution
     50%  116.58ms
     75%  143.79ms
     90%  201.09ms
     99%  481.49ms
  4900 requests in 15.10s, 72.07MB read
  Socket errors: connect 0, read 19, write 0, timeout 0
Requests/sec:    324.51
Transfer/sec:      4.77MB

列名解釋

Latency:响应时间 Req/Sec:每个线程每秒钟的完成的请求数

Avg:平均 Max:最大 Stdev:标准差 +/- Stdev: 正负一个标准差占比

Requests/sec : QPS(每秒请求数)

lua腳本支持

官方例子

參考鏈接

http://zjumty.iteye.com/blog/2221040/ http://www.cnblogs.com/savorboard/p/wrk.html/

–EOF–


本文链接:壓力測試
作者: Spencer
出处: https://spencerzhang.github.io
本文基于 知识共享署名-相同方式共享 4.0 国际许可协议发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的署名 Spencer及链接。