日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux下进行Web服务器压力(并发)测试工具http_load、webbench、ab、Siege、autobench简单使用教程(转)...

發布時間:2023/12/10 linux 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下进行Web服务器压力(并发)测试工具http_load、webbench、ab、Siege、autobench简单使用教程(转)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、http_load

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

http_load以并行復用的方式運行,用以測試web服務器的吞吐量與負載。但是它不同于大多數壓力測試工

具,它可以以一個單一的進程運行,一般不會把客戶機搞死。還可以測試HTTPS類的網站請求。

下載地址:http://soft.vpser.net/test/http_load/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 urls.txt也是可以的。我們把參數給大家簡單說明一下。

-parallel 簡寫-p :含義是并發的用戶進程數。 -fetches 簡寫-f :含義是總計的訪問次數 -rate 簡寫-p :含義是每秒的訪問頻率 -seconds簡寫-s :含義是總計的訪問時間

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

如下:

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

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

命令:./http_load -rate 5 -seconds 10 urllist.txt說明執行了一個持續時間10秒的測試,每秒的頻率為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 20049

結果分析:

  • 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這個選項,即服務器每秒能夠響應的查詢次數,用這個指標來衡量性能。似乎比 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.5make && make install

會在當前目錄生成webbench可執行文件,直接可以使用了

用法:

webbench -c 并發數 -t 運行測試時間 URL

如:

webbench -c 5000 -t 120 http://www.vpser.net

三、ab

ab是apache自帶的一款功能強大的測試工具

安裝了apache一般就自帶了

用法可以查看它的說明

$ ./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)

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

例如:

./ab -c 1000 -n 100 http://www.vpser.net/index.php

這個表示同時處理1000個請求并運行100次index.php文件.

四、Siege

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

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

Siege下載:http://soft.vpser.net/test/siege/siege-2.67.tar.gz

安裝:

#解壓: tar -zxf siege-2.67.tar.gz $進入解壓目錄: cd siege-2.67/ #安裝: ./configure ; make make install

使用

siege -c 200 -r 10 -f example.url

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

example.url內容:

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

結果說明

Lifting the server siege… done. Transactions: 3419263 hits //完成419263次處理 Availability: 100.00 % //100.00 % 成功率 Elapsed time: 5999.69 secs //總共用時 Data transferred: 84273.91 MB //共數據傳輸84273.91 MB Response time: 0.37 secs //相應用時1.65秒:顯示網絡連接的速度 Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次處理:表示服務器后 Throughput: 14.05 MB/sec //平均每秒傳送數據 Concurrency: 213.42 //實際最高并發數 Successful transactions: 2564081 //成功處理次數 Failed transactions: 11 //失敗處理次數 Longest transaction: 29.04 //每次傳輸所花最長時間 Shortest transaction: 0.00 //每次傳輸所花最短時間

五、利用autobench工具結合httperf命令對web服務器進行測試,得出該服務器可以承載的最大并發連接數與最佳并發數。

1、Httperf

httperf是一款高性能的HTTP測試工具,使用它我們可以準確定位服務器的并發連接能力。下面介紹一下它的主要特征

  • (1) 可以觀察測試客戶端(并非被測服務器)在發起壓力測試時的負載情況。這樣在測試高并發的情況下可以準確的分析問題。(被測服務器無法承載高并發還是測試客戶端無法發起過多請求)
  • (2)支持HTTP/1.1和SSL
  • (3)可以生成可擴展的測試計劃

下載:http://code.google.com/p/httperf/downloads/list

安裝:

tar xvzf httperf-0.9.0.tar.gz cd httperf-0.9.0 ./configure make && make install

更多的使用方法參見man page。

2、autobench

autobench是一款基于httperf的Perl腳本。它會在一次測試中調用多次httperf來對web服務器進行測試,每次會按照給定的參數增加并發連接數,將 httperf的測試結果保存為CSV格式的文件,該文件可以被Excel直接讀取,方便生成測試報告。借助于autobench自帶的 bench2graph工具可以生成漂亮的測試結果對比圖

?

參考:

http://blog.51cto.com/510512/740219(以上內容轉自此篇文章)

?

總結

以上是生活随笔為你收集整理的Linux下进行Web服务器压力(并发)测试工具http_load、webbench、ab、Siege、autobench简单使用教程(转)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。