ab benchmark and chart
apache benchmart又稱ab benchmark
是一套簡單好用的壓測工具
測試的參數網路上眾多說明
或直接執行"ab"指令,也可以看到說明
# ab
ab: wrong number of arguments
Usage: ab [options] [http[s]://]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
-b windowsize Size of TCP send/receive buffer, in bytes
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header for POSTing, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-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
-r Don't exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
這邊介紹將ab的結果製圖的工具gnuplot
透過執行gnuplot指令,可以進入互動模式
# gnuplot
G N U P L O T
Version 4.4 patchlevel 3
last modified March 2011
System: SunOS 5.11
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help seeking-assistance"
immediate help: type "help"
plot window: hit 'h'
Terminal type set to 'unknown'
gnuplot>
互動模式下可以輸入製圖的參數:
gnuplot> set terminal png
Terminal type set to 'png'
Could not find/open font when opening font "arial", using internal non-scalable font
Options are 'nocrop medium size 640,480 '
gnuplot> set output "ApacheBenchmarkResults.png" (設定圖片名稱)
gnuplot> set title "Benchmark from Server X"
gnuplot> set size 1,0.5
gnuplot> set key left top
gnuplot> set xlabel 'request'
gnuplot> set ylabel 'ms'
gnuplot> plot "out.dat" using 10 with lines title 'Benchmark from Server X' (這句是真正產圖的重點)
gnuplot> exit (離開)
圖形產出如下:
另外修改參數,讓圖形平滑化:
set terminal png
set output "ApacheBenchmarkResults.png"
set title "Benchmark from Server X"
set size 1,0.5
set key left top
set xlabel 'request'
set ylabel 'ms'
plot "out.dat" using 9 smooth sbezier with lines title "nodejs"
exit
產出圖形如下:
給有需要的人參考...