wrk 是用C語言寫的一套http benchmark 工具
可以幫助我們處理簡易的HTTP 性能測試
安裝 wrk
git clone https://github.com/wg/wrk.git
cd wrk
make
新版本wrk會自動幫我們檢查及安裝 openssl
如果執行過程發生 fatal error: openssl/ssl.h: No such file or directory
則手動安裝 openssl 即可:
sudo yum install openssl-devel
測試
wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
//or
./wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html
命令列參數說明
-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.
參考 https://github.com/wg/wrk http://zjumty.iteye.com/blog/2221040