在Ubuntu 20.04 使用httperf 做網站壓力測試
httperf 可用來測試網站伺服器的效能,看看網路服務的極限在哪!
sudo apt-get update
安裝httperf
sudo apt-get install httperf
移除httperf
sudo apt-get remove httperf
網站壓力測試
sudo httperf --server xxx.com --port 443 --num-conn 450 --num-call 1 --rate 45 --timeout 5
- num-conn:共發多少個請求,設置總連接數為 100。
- num-call:每個連接發送 1 個 HTTPS 請求。
- rate:每秒發起 45 個連接。
- timeout:如果網站伺服器沒有在5秒內回覆,即視為失敗而列入統計
Maximum connect burst length: 1
Total: connections 450 requests 450 replies 450 test-duration 9.982 s
總共在9.982秒內建立了450個連線及450個要求,並收到受測網站伺服器回覆450個要求。
Connection rate: 45.1 conn/s (22.2 ms/conn, <=1 concurrent connections)
每秒鐘產生45個連線數,而且最多會同時送出1個連線數至受測的網站伺服器上。
Connection time [ms]: min 2.4 avg 3.6 max 16.4 median 3.5 stddev 1.5
每個連線所使用的存活週期,連線的存活週期最小(min)用了2.4毫秒,最長用了16.4毫秒,平均(avg)花費3.6毫秒,其存活週期的中位數時間為3.5毫秒,標準差時間用了1.5毫秒。
Connection time [ms]: connect 1.9
成功與受測的網站伺服器建立TCP連接所使用的平 均時間1.9毫秒
Connection length [replies/conn]: 1.000
Request rate: 45.1 req/s (22.2 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 45.0 avg 45.0 max 45.0 stddev 0.0 (1 samples)
Reply time [ms]: response 1.7 transfer 0.0
網站伺服器平均的回覆時間1.7毫秒
Reply size [B]: header 195.0 content 0.0 footer 0.0 (total 195.0)
Reply status: 1xx=0 2xx=0 3xx=450 4xx=0 5xx=0
CPU time [s]: user 4.69 system 5.29 (user 47.0% system 53.0% total 100.0%)
Net I/O: 11.8 KB/s (0.1*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
這次測試結果顯示沒有任何錯誤:
- 總錯誤數: 0
- 客戶端超時: 0
- 套接字超時: 0
- 連接被拒: 0
- 連接重置: 0
- 文件描述符不可用: 0
- 地址不可用: 0
- 文件表已滿: 0
- 其他: 0
這表明伺服器在這次測試中表現非常穩定,所有請求都成功處理並回應。
發表評論
想要留言嗎?歡迎歡迎!