介紹:http_load以並行複用的方式運行,用以測試web服務器的吞吐量與負載。可是它不一樣於大多數壓力測試工具,它能夠以一個單一的進程運行,通常不會把客戶機搞死。還能夠測試HTTPS類的網站請求。linux
1、http_load安裝web
1)下載http_load安裝包服務器
A、能夠直接下載:wget http://acme.com/software/http_load/http_load-12mar2006.tar.gz併發
B、能夠直接下載到本地,而後經過CRT上傳到linux服務器。工具
2)安裝http_load性能
A、進入/usr/local目錄下建立man文件夾,並賦予權限;測試
[root@localhost ~]#cd /usr/localfetch
[root@localhost local]#mkdir man網站
[root@localhost local]#chmod 777 mancode
B、進man文件夾中,下載http_load安裝包;
[root@localhost local]#cd man
[root@localhost man]# wget http://acme.com/software/http_load/http_load-12mar2006.tar.gz
C、解壓、並安裝http_load-12mar2006.tar.gz包;
[root@localhost man]# tar zxvf http_load-12mar2006.tar.gz
[root@localhost man]# cd http_load-12mar2006
[root@localhost http_load-12mar2006]# make
[root@localhost http_load-12mar2006]# sudo make install
2、http_load使用
一、建立URL文件
因爲http_load運行的是URL文件,因此須要準備一個txt文件;因而,建立一個test.txt文件。
[root@localhost http_load-12mar2006]# touch test.txt
編輯test.txt文件:
[root@localhost http_load-12mar2006]# vi test.txt
輸入如圖地址後,保存並退出:
二、運行URL文件
[root@localhost http_load-12mar2006]# http_load -p 10 -s 10 test.txt
說明:
-parallel 簡寫-p :含義是併發的用戶進程數。
-fetches 簡寫-f :含義是總計的訪問次數
-rate 簡寫-p :含義是每秒的訪問頻率
-seconds簡寫-s :含義是總計的訪問時間
因爲我是虛擬機里弄的,因此會看到以下圖:
三、結果分析
1)圖中「96 fetches, 10 max parallel, 1.1037e+07 bytes, in 10 seconds」
解釋:在上面的測試中運行了96個請求,最大的併發進程數是10,總計傳輸的數據是1.1037e+07bytes,運行的時間是10秒
2)圖中「114968 mean bytes/connection」
解釋:每一鏈接平均傳輸的數據量1.1037e+07/96=114968
3)圖中「9.59998 fetches/sec, 1.10369e+06 bytes/sec」
解釋:每秒的響應請求爲9.59998,每秒傳遞的數據爲1.10369e+06 bytes/sec
4)圖中「msecs/connect: 99.3326 mean, 3005.02 max, 4.132 min」
解釋:每鏈接的平均響應時間是99.3326 msecs,最大的響應時間3005.02 msecs,最小的響應時間4.132 msecs
5)圖中「msecs/first-response: 71.5985 mean, 708.071 max, 4.093 min」
6)圖中「HTTP response codes:code 200 — 96」
解釋:打開的頁面類型是200,若是出現403等過多就說明系統遇到瓶頸了。
說明:
通常使用http_load作壓力測試時,主要會考慮這「fetches/sec、msecs/connect 」兩個項的結果,即服務器每秒可以響應的查詢次數來衡量性能指標。
另外一方面能夠藉助nmon來監控linux服務器的CPU、MEN等進行分析。
http_load使用方式:
http_load -parallel 100 -fetches 10000
#100個併發執行10000次
http_load -parallel 100 -seconds 3600
#100個併發執行1小時
http_load -rate 100 -fetches 10000
#每秒100個請求頻率,請求10000次
http_load -rate 100 -seconds 3600
#每秒100個請求頻率執行1小時