wrk 安裝使用


==================== 安裝 ====================
https://github.com/wg/wrk/wiki

sudo yum -y groupinstall 'Development Tools'
sudo yum install -y openssl-devel git
git clone https://github.com/wg/wrk.git wrk
cd wrk
make
sudo cp wrk /usr/bin

==================== 使用 ====================

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)

wrk -c100 -t4 -d100s http://localhost:9981/api/test

test.lua

wrk.method="POST"

wrk.body=[[ {"jsonKey": "jsonValue"} ]]

wrk.headers["Content-Type"]="application/json; charset=utf-8"

wrk -c100 -t4 -d100s -stest.lua --latency http://localhost:9981/api/test

==================== 測試結果 ====================

Running 10s test @ http://localhost:9981/api/test 4 threads and 1000 connections // 線程數設置為cpu核心數或其2倍,設置不同的連接數以觀察吞吐量及響應時間情況 Thread Stats Avg Stdev Max +/- Stdev // 每條線程的狀態 Latency 70.08ms 8.76ms 127.28ms 81.70% // 完成一個請求所需要的響應時間 Req/Sec 3.55k 581.40 4.91k 68.50% // 每秒完成的請求數 Latency Distribution 50% 68.65ms 75% 72.67ms 90% 80.40ms 99% 99.73ms // 99%的請求完成一個請求所需要的響應時間 141270 requests in 10.05s, 265.27MB read // 規定時間內總請求數及傳送數據量 Requests/sec: 14053.75 // 每秒總共可以完成的請求數 Transfer/sec: 26.39MB // 每秒總共傳送數據量

 

wrk -c100 -t4 -d100s -stest.lua --latency http://localhost:9981/api/test


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM