歡迎光臨郝學(xué)武的blog。

          輕量級(jí)壓測(cè)工具

          Posted on 2011-11-11 15:33 陜西BOY 閱讀(648) 評(píng)論(0)  編輯  收藏

          一、http_load

          程序非常小,解壓后也不到100K

          http_load以并行復(fù)用的方式運(yùn)行,用以測(cè)試web服務(wù)器的吞吐量與負(fù)載。但是它不同于大多數(shù)壓力測(cè)試工

          具,它可以以一個(gè)單一的進(jìn)程運(yùn)行,一般不會(huì)把客戶機(jī)搞死。還可以測(cè)試HTTPS類的網(wǎng)站請(qǐng)求。

          下載地址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz
          安裝很簡(jiǎn)單
          #tar zxvf http_load-12mar2006.tar.gz
          #cd http_load-12mar2006
          #make && make install

          命令格式:http_load  -p 并發(fā)訪問(wèn)進(jìn)程數(shù)  -s 訪問(wèn)時(shí)間  需要訪問(wèn)的URL文件

          參數(shù)其實(shí)可以自由組合,參數(shù)之間的選擇并沒(méi)有什么限制。比如你寫成http_load -parallel 5 -seconds

          300 urls.txt也是可以的。我們把參數(shù)給大家簡(jiǎn)單說(shuō)明一下。
          -parallel 簡(jiǎn)寫-p :含義是并發(fā)的用戶進(jìn)程數(shù)。
          -fetches 簡(jiǎn)寫-f :含義是總計(jì)的訪問(wèn)次數(shù)
          -rate    簡(jiǎn)寫-p :含義是每秒的訪問(wèn)頻率
          -seconds簡(jiǎn)寫-s :含義是總計(jì)的訪問(wèn)時(shí)間

          準(zhǔn)備URL文件:urllist.txt,文件格式是每行一個(gè)URL,URL最好超過(guò)50-100個(gè)測(cè)試效果比較好.文件格式

          如下:
          http://www.vpser.net/uncategorized/choose-vps.html
          http://www.vpser.net/vps-cp/hypervm-tutorial.html
          http://www.vpser.net/coupons/diavps-april-coupons.html
          http://www.vpser.net/security/vps-backup-web-mysql.html
          例如:

          http_load -p 30 -s 60  urllist.txt
          參數(shù)了解了,我們來(lái)看運(yùn)行一條命令來(lái)看看它的返回結(jié)果
          命令:% ./http_load -rate 5 -seconds 10 urls說(shuō)明執(zhí)行了一個(gè)持續(xù)時(shí)間10秒的測(cè)試,每秒的頻率為5。

          49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds5916 mean bytes/connection4.89274

          fetches/sec, 28945.5 bytes/secmsecs/connect: 28.8932 mean, 44.243 max, 24.488 minmsecs/first

          -response: 63.5362 mean, 81.624 max, 57.803 minHTTP response codes: code 200 — 49 

          結(jié)果分析:
          1.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
          說(shuō)明在上面的測(cè)試中運(yùn)行了49個(gè)請(qǐng)求,最大的并發(fā)進(jìn)程數(shù)是2,總計(jì)傳輸?shù)臄?shù)據(jù)是289884bytes,運(yùn)行的時(shí)間是10.0148秒
          2.5916 mean bytes/connection說(shuō)明每一連接平均傳輸?shù)臄?shù)據(jù)量289884/49=5916
          3.4.89274 fetches/sec, 28945.5 bytes/sec
          說(shuō)明每秒的響應(yīng)請(qǐng)求為4.89274,每秒傳遞的數(shù)據(jù)為28945.5 bytes/sec
          4.msecs/connect: 28.8932 mean, 44.243 max, 24.488 min說(shuō)明每連接的平均響應(yīng)時(shí)間是28.8932 msecs

          ,最大的響應(yīng)時(shí)間44.243 msecs,最小的響應(yīng)時(shí)間24.488 msecs
          5.msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
          6、HTTP response codes: code 200 — 49     說(shuō)明打開(kāi)響應(yīng)頁(yè)面的類型,如果403的類型過(guò)多,那可能

          要注意是否系統(tǒng)遇到了瓶頸。
          特殊說(shuō)明:
          測(cè)試結(jié)果中主要的指標(biāo)是 fetches/sec、msecs/connect 這個(gè)選項(xiàng),即服務(wù)器每秒能夠響應(yīng)的查詢次數(shù),

          用這個(gè)指標(biāo)來(lái)衡量性能。似乎比 apache的ab準(zhǔn)確率要高一些,也更有說(shuō)服力一些。
          Qpt-每秒響應(yīng)用戶數(shù)和response time,每連接響應(yīng)用戶時(shí)間。
          測(cè)試的結(jié)果主要也是看這兩個(gè)值。當(dāng)然僅有這兩個(gè)指標(biāo)并不能完成對(duì)性能的分析,我們還需要對(duì)服務(wù)器的

          cpu、men進(jìn)行分析,才能得出結(jié)論

           

          二、webbench

          webbench是Linux下的一個(gè)網(wǎng)站壓力測(cè)試工具,最多可以模擬3萬(wàn)個(gè)并發(fā)連接去測(cè)試網(wǎng)站的負(fù)載能力。下載地址可以到google搜,我這里給出一個(gè)
          下載地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
          這個(gè)程序更小,解壓后不到50K,呵呵
          安裝非常簡(jiǎn)單
          #tar zxvf webbench-1.5.tar.gz
          #cd webbench-1.5
          #make && make install
          會(huì)在當(dāng)前目錄生成webbench可執(zhí)行文件,直接可以使用了

          用法:

          webbench -c 并發(fā)數(shù) -t 運(yùn)行測(cè)試時(shí)間 URL
          如:
          webbench -c 5000 -t 120 http://www.vpser.net

          三、ab
          ab是apache自帶的一款功能強(qiáng)大的測(cè)試工具
          安裝了apache一般就自帶了,
          用法可以查看它的說(shuō)明

          $ ./ab
          ./ab: wrong number of arguments
          Usage: ./ab [options] [http://]hostname[:port]/path
          Options are:
          -n requests Number of requests to perform
          -c concurrency Number of multiple requests to make
          -t timelimit Seconds to max. wait for responses
          -p postfile File containing data to POST
          -T content-type Content-type header for POSTing
          -v verbosity How much troubleshooting info to print
          -w Print out results in HTML tables
          -i Use HEAD instead of GET
          -x attributes String to insert as table attributes
          -y attributes String to insert as tr attributes
          -z attributes String to insert as td or th attributes
          -C attribute Add cookie, eg. ‘Apache=1234. (repeatable)
          -H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’
          Inserted after all normal header lines. (repeatable)
          -A attribute Add Basic WWW Authentication, the attributes
          are a colon separated username and password.
          -P attribute Add Basic Proxy Authentication, the attributes
          are a colon separated username and password.
          -X proxy:port Proxyserver and port number to use
          -V Print version number and exit
          -k Use HTTP KeepAlive feature
          -d Do not show percentiles served table.
          -S Do not show confidence estimators and warnings.
          -g filename Output collected data to gnuplot format file.
          -e filename Output CSV file with percentages served
          -h Display usage information (this message)
          參數(shù)眾多,一般我們用到的是-n 和-c
          例如:
          ./ab -c 1000 -n 100 http://www.vpser.net/index.php

          這個(gè)表示同時(shí)處理1000個(gè)請(qǐng)求并運(yùn)行100次index.php文件.
          四、Siege
          一款開(kāi)源的壓力測(cè)試工具,可以根據(jù)配置對(duì)一個(gè)WEB站點(diǎn)進(jìn)行多用戶的并發(fā)訪問(wèn),記錄每個(gè)用戶所有請(qǐng)求過(guò)程的相應(yīng)時(shí)間,并在一定數(shù)量的并發(fā)訪問(wèn)下重復(fù)進(jìn)行。
          官方:http://www.joedog.org/
          Siege下載:http://soft.vpser.net/test/siege/siege-2.67.tar.gz
          解壓:
          # tar -zxf siege-2.67.tar.gz
          進(jìn)入解壓目錄:
          # cd siege-2.67/
          安裝:
          #./configure ; make
          #make install

          使用
          siege -c 200 -r 10 -f example.url
          -c是并發(fā)量,-r是重復(fù)次數(shù)。 url文件就是一個(gè)文本,每行都是一個(gè)url,它會(huì)從里面隨機(jī)訪問(wèn)的。

          example.url內(nèi)容:

          http://www.licess.cn
          http://www.vpser.net
          http://soft.vpser.net

          結(jié)果說(shuō)明
          Lifting the server siege… done.
          Transactions: 3419263 hits //完成419263次處理
          Availability: 100.00 % //100.00 % 成功率
          Elapsed time: 5999.69 secs //總共用時(shí)
          Data transferred: 84273.91 MB //共數(shù)據(jù)傳輸84273.91 MB
          Response time: 0.37 secs //相應(yīng)用時(shí)1.65秒:顯示網(wǎng)絡(luò)連接的速度
          Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次處理:表示服務(wù)器后
          Throughput: 14.05 MB/sec //平均每秒傳送數(shù)據(jù)
          Concurrency: 213.42 //實(shí)際最高并發(fā)數(shù)
          Successful transactions: 2564081 //成功處理次數(shù)
          Failed transactions: 11 //失敗處理次數(shù)
          Longest transaction: 29.04 //每次傳輸所花最長(zhǎng)時(shí)間
          Shortest transaction: 0.00 //每次傳輸所花最短時(shí)間


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          posts - 17, comments - 65, trackbacks - 0, articles - 28

          Copyright © 陜西BOY

          主站蜘蛛池模板: 固原市| 佛坪县| 西乌珠穆沁旗| 辉县市| 彭州市| 齐齐哈尔市| 水富县| 灌南县| 南和县| 奇台县| 丹棱县| 抚顺市| 威信县| 恩平市| 金堂县| 鹤岗市| 平顶山市| 阳谷县| 平安县| 钦州市| 古田县| 丘北县| 旅游| 盖州市| 杭锦后旗| 南溪县| 株洲市| 丘北县| 田阳县| 当阳市| 分宜县| 汉寿县| 平度市| 新蔡县| 沂南县| 海盐县| 滨海县| 社会| 安陆市| 扎赉特旗| 凤翔县|