標籤:
HTTP效能測試
web效能測試的方法請參考此串連說明:http://www.xenoclast.org/doc/benchmark/
1. httperf
ftp://ftp.hpl.hp.com/pub/httperf/ 下載
解壓然後安裝,執行程式在安裝目錄下的src目錄中
./httperf –server 192.168.210.155 –port 10002 –uri /index.html –rate 300 –num-conn 30000 –num-call 1 –timeout 5*
??num?calls=_It specifies the total number of calls to issue on each connection before closing it
??num?connsthe total number of connections to create
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 51
Total: connections 30000 requests 30000 replies 30000 test-duration 100.004 s
Connection rate: 300.0 conn/s (3.3 ms/conn, <=52 concurrent connections)
Connection time [ms]: min 0.5 avg 3.5 max 113.7 median 3.5 stddev 4.6
Connection time [ms]: connect 1.2
Connection length [replies/conn]: 1.000
Request rate: 300.0 req/s (3.3 ms/req)
Request size [B]: 78.0
Reply rate [replies/s]: min 290.2 avg 300.0 max 309.8 stddev 3.3 (19 samples)
Reply time [ms]: response 2.3 transfer 0.1
Reply size [B]: header 238.0 content 612.0 footer 0.0 (total 850.0)
Reply status: 1xx=0 2xx=30000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 52.07 system 47.29 (user 52.1% system 47.3% total 99.4%)
Net I/O: 271.9 KB/s (2.2*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
total: 表示總體情況
Connection:tcp 串連的相關統計資訊,Connection length可能>1(由於persistent-connections)
Request rate:HTTP報文的發送統計資訊
Reply rate: time表示發送第一個包到接收第一個包的時間, transfer表示讀取接收報文的時間
2.autobench
對httperf進行了封裝,不僅僅只測試一個條件的結果,可以連續增加測試量,從而測試出效能的瓶頸
: http://www.xenoclast.org/autobench/
預設的設定檔如下所示:
more autobench.conf
注意: 一定要將設定檔copy到所用使用者的家目錄下,因此程式執行需要讀取這個檔案;安裝後預設在/usr/local/etc/autobench.conf
# Autobench Configuration File
# host1, host2
# The hostnames of the servers under test
# Eg. host1 = iis.test.com
# host2 = apache.test.com
host1 = testhost1
host2 = testhost2
# uri1, uri2
# The URI to test (relative to the document root). For a fair comparison
# the files should be identical (although the paths to them may differ on the
# different hosts)
uri1 = /
uri2 = /
# port1, port2
# The port number on which the servers are listening
port1 = 80
port2 = 80
# low_rate, high_rate, rate_step
# The ‘rate‘ is the number of number of connections to open per second.
# A series of tests will be conducted, starting at low rate,
# increasing by rate step, and finishing at high_rate.
# The default settings test at rates of 20,30,40,50...180,190,200
low_rate = 20
high_rate = 200
rate_step = 10
# num_conn, num_call
# num_conn is the total number of connections to make during a test
# num_call is the number of requests per connection
# The product of num_call and rate is the the approximate number of
# requests per second that will be attempted.
num_conn = 5000
num_call = 10
# timeout sets the maximimum time (in seconds) that httperf will wait
# for replies from the web server. If the timeout is exceeded, the
# reply concerned is counted as an error.
timeout = 5
# output_fmt
# sets the output type - may be either "csv", or "tsv";
output_fmt = tsv
## Config for distributed autobench (autobench_admin)
# clients
# comma separated list of the hostnames and portnumbers for the
# autobench clients. No whitespace can appear before or after the commas.
# clients = bench1.foo.com:4600,bench2.foo.com:4600,bench3.foo.com:4600
clients = localhost:4600
執行測試命令
./autobench –single_host –host1 192.168.210.155 –port1 10002 –uri1 /index.html –quiet –low_rate 20 –high_rate 200 –rate_step 20 –num_call 10 –num_conn 5000 –timeout 5 –file results.tsv
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
如果不添加參數,則預設使用設定檔中的參數
最後的結果是tsv格式的檔案,可以使用1.10版本後內建的工具,通過gnuplot畫圖得出圖形結果
bench2graph takes a TSV format autobench results file, and uses gnuplot to graph the results, producing output in Postscript.
注意產生的圖片格式是Postscript
./bench2graph results-1.tsv results-1.ps
windows下建議使用 GhostView來開啟圖片
來自為知筆記(Wiz)
附件列表
HTTP效能測試