萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

Linux 安裝 http_load 壓力測試工具:下載、編譯、參數詳解、實戰範例

http_load 是輕量級 HTTP 壓力測試工具,支援並發進程 (-p) 或固定頻率 (-r)、總請求數 (-f) 或總時間 (-s),適合快速評估 Web 伺服器吞吐量。本文記錄下載編譯與實戰參數範例。

下載與編譯安裝

cd /root
wget https://acme.com/software/http_load/http_load-12mar2006.tar.gz
tar xzf http_load-12mar2006.tar.gz
cd http_load-12mar2006
make
# 產生 http_load 二進制檔於當前目錄

http_load 編譯

核心參數說明

參數縮寫說明
-parallel N-p N並發進程數 (同時 N 個用戶)
-rate N-r N每秒請求頻率 (互斥 -p)
-fetches N-f N總請求次數 (互斥 -s)
-seconds N-s N總測試時間 (秒) (互斥 -f)
-checksum-c驗證回應內容校驗和
-throttle-t限制頻寬 (模擬慢速連線)
-proxy host:port透過代理伺服器測試
-verbose-v詳細輸出每個請求資訊
-timeout secs請求逾時秒數
-sip sip_file指定來源 IP 池檔案

必選組合:-p 或 -r (二擇一) + -f 或 -s (二擇一) + url_file (每行一個 URL)。

實戰範例

範例 1:50 併發、持續 10 秒

./http_load -parallel 50 -seconds 10 urls.txt

範例 2:固定 50 req/s、共 5000 請求

./http_load -rate 50 -fetches 5000 urls.txt

範例 3:5 併發、1000 請求 (評估平均 QPS)

./http_load -parallel 5 -fetches 1000 urls.txt

輸出結果解讀:

1000 fetches, 5 max parallel, 6e+06 bytes, in 58.1026 seconds
6000 mean bytes/connection
17.2109 fetches/sec, 103266 bytes/sec
msecs/connect: 0.403 mean, 68.603 max, 0.194 min
msecs/first-response: 284.133 mean, 5410.13 max, 55.735 min
HTTP response codes:
  code 200 -- 1000
  • fetches/sec (QPS):每秒成功請求數,核心效能指標 (例中 17.2 QPS)。
  • bytes/sec:頻寬吞吐量。
  • msecs/connect:TCP 連線建立延遲。
  • msecs/first-response:TTFB (首字節時間)。
  • HTTP 200 計數:成功回應數,若有 5xx/4xx 需檢查應用/伺服器日誌。

urls.txt 範例


https://example.com/
https://example.com/page1.html
https://example.com/api/data

測試時會隨機從檔案選取 URL。http_load 功能簡潔、無依賴、編譯即用,適合 CI/CD 流程快速基準測試。

copyright © 萬盛學電腦網 all rights reserved