到http://www.acme.com/software/http_load/ 下載http_load ,安裝也很簡單直接make;make instlall 就行。
如果你需要測試https,你必須將 Makefile中
# CONFIGURE: If you want to compile in support for https, uncomment these
# definitions.? You will need to have already built OpenSSL, available at
# http://www.openssl.org/? Make sure the SSL_TREE definition points to the
# tree with your OpenSSL installation - depending on how you installed it,
# it may be in /usr/local instead of /usr/local/ssl.
SSL_TREE =??? /usr
SSL_DEFS =??? -DUSE_SSL
SSL_INC =??? -I$(SSL_TREE)/include
SSL_LIBS =??? -L$(SSL_TREE)/lib -lssl -lcrypto
由于使用到openssl,你必須安裝openssl和相應的開發環境
apt-get install openssl
apt-get install libssl-dev
find -name ssl.h
/usr/include/openssl/ssl.h
所以上面紅色字體部分必須修改
http_load 是支持 https 的,但是Makefile 要作些修改(具體看Makefile的注釋),修改后可能會報鏈接錯誤,提示ssl 找不到 dlopen 等。
此時,需要繼續修改Makefile
LDFLAGS =? -s $(SSL_LIBS) $(SYSV_LIBS)
改為
LDFLAGS =??? -s $(SSL_LIBS) $(SYSV_LIBS) -rdynamic -ldl
如果使用dl*函數,需要-ldl
我們把參數給大家簡單說明一下。-parallel簡寫-p :含義是并發的用戶進程數。
-fetches 簡寫-f:含義是總計的訪問次數
-rate??? 簡寫-p:含義是每秒的訪問頻率
-seconds簡寫-s:含義是總計的訪問時間
urls.txt 是一個url 列表,每個url 單獨的一行。當然也可以直接跟一個url 而不是url 列表文件。
實例:
- http_load?-rate?5?-seconds?10?urls??
- 49?fetches,?2?max?parallel,?289884?bytes,?in?10.0148?seconds??
- 5916?mean?bytes/connection??
- 4.89274?fetches/sec,?28945.5?bytes/sec??
- msecs/connect:?28.8932?mean,?44.243?max,?24.488?min??
- msecs/first-response:?63.5362?mean,?81.624?max,?57.803?min??
- HTTP?response?codes:??
- ??code?200?--?49??
1.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
說明在上面的測試中運行了49個請求,最大的并發進程數是2,總計傳輸的數據是289884bytes,運行的時間是10.0148秒
2.5916 mean bytes/connection
說明每一連接平均傳輸的數據量289884/49=5916
3.4.89274 fetches/sec, 28945.5 bytes/sec
說明每秒的響應請求為4.89274,每秒傳遞的數據為28945.5 bytes/sec
4.msecs/connect: 28.8932 mean, 44.243 max, 24.488 min
說明每連接的平均響應時間是28.8932 msecs,最大的響應時間44.243 msecs,最小的響應時間24.488 msecs
5.msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
?6、HTTP response codes: code 200 -- 49
說明打開響應頁面的類型,如果403的類型過多,那可能要注意是否系統遇到了瓶頸。
特殊說明:這里,我們一般會關注到的指標是fetches/sec、msecs/connect
他們分別對應的常用性能指標參數Qpt-每秒響應用戶數和response time,每連接響應用戶時間。測試的結果主要也是看這兩個值。當然僅有這兩個指標并不能完成對性能的分析,我們還需要對服務器的cpu、men進行分析,才能得出結論
Sample run:
% ./http_load -rate 5 -seconds 10 urls 49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds 5916 mean bytes/connection 4.89274 fetches/sec, 28945.5 bytes/sec msecs/connect: 28.8932 mean, 44.243 max, 24.488 min msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min HTTP response codes:code 200 -- 49