幾款Web服務器性能壓力測試工具


一、http_load

程序非常小,解壓后也不到100K
http_load以並行復用的方式運行,用以測試web服務器的吞吐量與負載。
但是它不同於大多數壓力測試工具,它可以以一個單一的進程運行,一般不會把客戶機搞死。
還可以測試HTTPS類的網站請求。
下載地址:http_load-12mar2006.tar.gz

安裝很簡單

#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006 #make && make install

基本用法:

http_load  -p 並發訪問進程數  -s 訪問時間  需要訪問的URL文件

參數其實可以自由組合,參數之間的選擇並沒有什么限制。
比如你寫成http_load  -parallel  5  -seconds  300  urllist.txt也是可以的。
我們把參數給大家簡單說明一下。
-parallel   簡寫-p :含義是並發的用戶進程數。
-fetches   簡寫-f :含義是總計的訪問次數
-rate        簡寫-p :含義是每秒的訪問頻率
-seconds 簡寫-s :含義是總計的訪問時間

准備URL文件:urllist.txt,文件格式是每行一個URL,URL最好超過50-100個測試效果比較好。

文件格式如下:

  1.  
    http://www.qixing318.com/
  2.  
    http://www.qixing318.com/blog/
  3.  
    http://www.qixing318.com/signin/
  4.  
    http://www.qixing318.com/signup/
  5.  
    http://www.qixing318.com/article/a-quick-look-at-the-redis-source-code.html
  6.  
    http://www.qixing318.com/article/how-the-browser-end-encryption.html
  7.  
    http://www.qixing318.com/article/jquery-form-validation-plug-in-validate.js-the-basic-usage.html
  8.  
    http://www.qixing318.com/article/use-flash-plugin-swfupload-head-is-upload-the-screenshot-in-two-ways.html
  9.  
    http://www.qixing318.com/article/should-make-your-site-using-html5.html
  10.  
    http://www.qixing318.com/article/simple-to-understand-linux-memory-allocation-mechanism.html
  11.  
    http://www.qixing318.com/article/organize-the-sphinx-api-based-on-php.html
  12.  
    http://www.qixing318.com/article/jquery-1-9-removed-browser-method-alternatives.html
  13.  
    http://www.qixing318.com/article/the-installation-of-fedora-under-chinese-search-sphinx-configuration.html
  14.  
    http://www.qixing318.com/article/schema-org-tag-was-used-to-optimize-web-pages.html
  15.  
    http://www.qixing318.com/article/jquery-reference-manual-tutorials-and-tools.html
  16.  
    http://www.qixing318.com/article/falling-in-love-with-bike-30-reasons.html
  17.  
    http://www.qixing318.com/article/online-test-tools-browserstack-cross-browser-compatibility.html
  18.  
    http://www.qixing318.com/article/talk-about-javascript-image-preloading-technology.html
  19.  
    http://www.qixing318.com/article/brokeback-mountain.html
  20.  
    http://www.qixing318.com/article/sql-index-caused-performance-issues.html
  21.  
    http://www.qixing318.com/article/use-python-scapy-reporter.html
  22.  
    http://www.qixing318.com/article/a-python-web-attack-script.html

例如:

http_load -p 30 -s 60 urllist.txt

參數了解了,我們來看運行一條命令來看看它的返回結果如下:

 

結果分析:

1、294 fetches, 30 max parallel, 3.83835e+06 bytes, in 60.0026 seconds
說明在上面的測試中運行了294個請求,最大的並發進程數是30,總計傳輸的數據是3.83835e+06bytes,運行的時間是60.0026秒
2、13055.6 mean bytes/connection
說明每一連接平均傳輸的數據量3.83835e+06/294=13055.6
3、4.89979 fetches/sec, 63969.7 bytes/sec
說明每秒的響應請求為4.89979,每秒傳遞的數據為63969.7 bytes/sec
4、msecs/connect: 312.009 mean, 1319.57 max, 209.994 min
說明每連接的平均響應時間是312.009 msecs,最大的響應時間1319.57 msecs,最小的響應時間209.994 msecs
5、msecs/first-response: 1191.01 mean, 10212.4 max, 220.78 min
6、HTTP response codes: 
    code 200  --  127 
    code 502  --  166
說明打開響應頁面的類型
如果403的類型過多,那可能要注意是否系統遇到了瓶頸。
特殊說明:
測試結果中主要的指標是 fetches/sec、msecs/connect 這個選項,即服務器每秒能夠響應的查詢次數。
用這個指標來衡量性能。似乎比 apache的ab准確率要高一些,也更有說服力一些。
Qpt-每秒響應用戶數和response time,每連接響應用戶時間。
測試的結果主要也是看這兩個值。
當然僅有這兩個指標並不能完成對性能的分析,我們還需要對服務器的cpu、men進行分析,才能得出結論。

二、webbench

webbench是Linux下的一個網站壓力測試工具,最多可以模擬3萬個並發連接去測試網站的負載能力。
下載地址可以到google搜,我這里給出一個
下載地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
這個程序更小,解壓后不到50K,呵呵
安裝非常簡單

#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5 #make && make install

會在當前目錄生成webbench可執行文件,直接可以使用了
用法:webbench -c 並發數 -t 運行測試時間 URL

例如:

#webbench -c 1000 -t 130 http://www.qixing318.com

三、ab

ab是apache自帶的一款功能強大的測試工具。
安裝了apache一般就自帶了。
用法可以查看它的說明

#./ab

參數眾多,一般我們用到的是-n 和-c
例如:

#webbench -c 1000 -t 130 http://www.qixing318.com/index.php

這個表示同時處理1000個請求並運行130次index.php文件。

四、Siege

一款開源的壓力測試工具,可以根據配置對一個WEB站點進行多用戶的並發訪問,記錄每個用戶所有請求過程的相應時間,並在一定數量的並發訪問下重復進行。

Siege官方:http://www.joedog.org/

Siege下載:http://www.joedog.org/pub/siege/siege-latest.tar.gz

Siege解壓並安裝:

# tar -zxvf siege-latest.tar.gz
# cd siege-latest/ #./configure #make #make install

Siege使用:

#siege -c 100 -r 10 -f site.url

-c是並發量,-r是重復次數。 
url文件就是一個文本,每行都是一個url,它會從里面隨機訪問的。

site.url內容:

http://www.qixing318.com/
http://www.zendsns.com/ http://www.qixing.info/

測試結果:

結果說明:

Transactions: 550 hits //完成550次處理
Availability: 55.00 % //55.00 % 成功率
Elapsed time: 31.32 secs //總共用時
Data transferred: 1.15 MB //共數據傳輸1.15 MB
Response time: 3.04 secs //顯示網絡連接的速度
Transaction rate: 17.56 trans/sec //均每秒完成 17.56 次處理:表示服務器后
Throughput: 0.04 MB/sec //平均每秒傳送數據
Concurrency: 53.44 //實際最高並發數
Successful transactions: 433 //成功處理次數
Failed transactions: 450 //失敗處理次數
Longest transaction: 15.50 //每次傳輸所花最長時間
Shortest transaction: 0.42 //每次傳輸所花最短時間


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM