chun 2009-5-4 16:08
[轉貼] 測試 Apache Web Server 效能測試指令 ab
http://ns2.ublink.org/phpbb/viewtopic.php?p=2043&sid=92b7b8d3a8bf94727f566c8e7d0e461a<br><br>有時候想要了解自己的 Web Server 的效能如何,這時候可以使用 Apache 內含的效能測試程式 - ab (Apache HTTP Server Benchmarking Tool)。
<br>
<br>先來測試一下
<br># /usr/bin/ab -c 10 -n 1000 <!-- m --><a class="postlink" href="http://localhost/">http://localhost/</a><!-- m -->
<br>-c 10:代表同時有 10 個連線
<br>-n 1000:代表連續測試 1000 次
<br>
<br>其它 ab 指令的用法:
<br>Usage: /usr/bin/ab [options] [http[s]://]hostname[:port]/path
<br>Options are:
<br> -n requests Number of requests to perform
<br> -c concurrency Number of multiple requests to make
<br> -t timelimit Seconds to max. wait for responses
<br> -p postfile File containing data to POST
<br> -T content-type Content-type header for POSTing
<br> -v verbosity How much troubleshooting info to print
<br> -w Print out results in HTML tables
<br> -i Use HEAD instead of GET
<br> -x attributes String to insert as table attributes
<br> -y attributes String to insert as tr attributes
<br> -z attributes String to insert as td or th attributes
<br> -C attribute Add cookie, eg. 'Apache=1234. (repeatable)
<br> -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
<br> Inserted after all normal header lines. (repeatable)
<br> -A attribute Add Basic WWW Authentication, the attributes
<br> are a colon separated username and password.
<br> -P attribute Add Basic Proxy Authentication, the attributes
<br> are a colon separated username and password.
<br> -X proxy:port Proxyserver and port number to use
<br> -V Print version number and exit
<br> -k Use HTTP KeepAlive feature
<br> -d Do not show percentiles served table.
<br> -S Do not show confidence estimators and warnings.
<br> -g filename Output collected data to gnuplot format file.
<br> -e filename Output CSV file with percentages served
<br> -h Display usage information (this message)
<br> -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
<br> -f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
<br>
<br>
<br>This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
<br>Copyright 1996 Adam Twiss, Zeus Technology Ltd, <!-- m --><a class="postlink" href="http://www.zeustech.net/">http://www.zeustech.net/</a><!-- m -->
<br>Copyright 2006 The Apache Software Foundation, <!-- m --><a class="postlink" href="http://www.apache.org/">http://www.apache.org/</a><!-- m -->
<br>Benchmarking localhost (be patient)
<br>Completed 100 requests
<br>Completed 200 requests
<br>Completed 300 requests
<br>Completed 400 requests
<br>Completed 500 requests
<br>Completed 600 requests
<br>Completed 700 requests
<br>Completed 800 requests
<br>Completed 900 requests
<br>Finished 1000 requests
<br>
<br># Aaache 的版本
<br>Server Software: Apache/2.2.3
<br># 主機的位址
<br>Server Hostname: localhost
<br># 主機的埠號
<br>Server Port: 80
<br>
<br># 網頁的路徑
<br>Document Path: /
<br># 網頁的大小
<br>Document Length: 5044 bytes
<br>
<br># 同時的連線數
<br>Concurrency Level: 10
<br># 所花費的時間
<br>Time taken for tests: 1.979964 seconds
<br># 測試的次數
<br>Complete requests: 1000
<br># 失敗的次數
<br>Failed requests: 0
<br># 寫入失敗的次數
<br>Write errors: 0
<br>Non-2xx responses: 1000
<br># 總共傳輸的資料量
<br>Total transferred: 5241000 bytes
<br># 總共傳輸的網頁資料量
<br>HTML transferred: 5044000 bytes
<br># 每秒所能接受的連線請求
<br>Requests per second: 505.06 [#/sec] (mean)
<br># 總共花費的時間
<br>Time per request: 19.800 [ms] (mean)
<br># 單一連線測試所花費的時間
<br>Time per request: 1.980 [ms] (mean, across all concurrent requests)
<br># 資料傳輸率
<br>Transfer rate: 2584.90 [Kbytes/sec] received
<br>
<br># 測試的報表
<br>Connection Times (ms)
<br> min mean[+/-sd] median max
<br>Connect: 0 0 0.3 0 4
<br>Processing: 3 17 164.3 4 1976
<br>Waiting: 3 16 164.3 3 1975
<br>Total: 3 17 164.5 4 1978
<br>
<br># 每個階段所花費的時間單位(1/1000 秒)
<br>Percentage of the requests served within a certain time (ms)
<br> 50% 4
<br> 66% 4
<br> 75% 4
<br> 80% 4
<br> 90% 4
<br> 95% 4
<br> 98% 5
<br> 99% 21
<br> 100% 1978 (longest request)<br>