服务器并发能力测试 Apache Beach
1.打开windows cmd(以下数据兼为windows xp平台运行数据)2.Cd 至Apache bin目录。3.运行ab.exe( ApacheBench command line utility)Java代码Usage: ab hostname[:port]/path Options are: -n requests Number of requests to perform -c concurrencyNumber 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 -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)Usage: ab hostname[:port]/pathOptions are:-n requests Number of requests to perform-c concurrencyNumber 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-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 attributesare a colon separated username and password.-P attribute Add Basic Proxy Authentication, the attributesare 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)D:\wamp\bin\apache\Apache2.2.11\bin>4.输入测试数据-n1000 -c10 http://localhost/oop5.php-n1000 表示总请求数为1000-c10 表示并发用户数为10http://localhost/oop5.php 表示请求的超链接地址This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking localhost (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.2.11被测试的web服务器名称,它来自HTTP响应数据的头信息Server Hostname: localhost请求URL 中主机部分名称,它来自HTTP请求数据的头信息Server Port: 80 被测试web服务器的监听端口Document Path: /oop5.php表示请求URL中的根绝对路径,它来自HTTP请求数据的头信息Document Length: 222 bytes 表示HTTP响应数据的正文长度Concurrency Level: 10并发数Time taken for tests: 5.125 seconds 表示所有请求被处理完成所需要的总时间Complete requests: 1000完成的实际请求数Failed requests: 0 失败的请求数Write errors: 0 请求写入失败的次数 Total transferred: 409000 bytes 表示所有请求的响应数据长度总和(header length + context length)HTML transferred: 222000 bytes 总的响应数据中正文长度(context length)Requests per second: 195.12 [#/sec] (mean) 吞吐率= Complete requests / Time taken for testsTime per request: 51.250 (mean)用户平均请求等待时间Time per request: 5.125 (mean, across all concurrent requests) 服务器平均处理请求时间 Transfer rate: 77.93 received表示请求在单位时间内从服务器获取的数据长度Connection Times (ms)minmean[+/-sd] median maxConnect: 0 0 2.1 0 16Processing: 16 51 7.5 47 78Waiting: 16 51 7.4 47 78Total: 16 51 7.6 47 78Percentage of the requests served within a certain time (ms)每个请求处理时间分布情况50% 4766% 4775% 6380% 6390% 6395% 6398% 6399% 63100% 78 (longest request)分析以上关键数据吞吐率Requests per second : 195.12 [#/sec] (mean)请求等待时间Time per request :51.250 (mean)请求处理时间 Time per request :5.125 (mean, across all concurrent requests)5. 继续测试-n1000 -c100http://localhost/oop5.php并发数设置为100,运行结果为Server Software: Apache/2.2.11Server Hostname: localhostServer Port: 80Document Path: /oop5.phpDocument Length: 222 bytesConcurrency Level: 100Time taken for tests: 5.672 secondsComplete requests: 1000Failed requests: 0Write errors: 0Total transferred: 409000 bytesHTML transferred: 222000 bytesRequests per second: 176.31 [#/sec] (mean)Time per request: 567.188 (mean)Time per request: 5.672 (mean, across all concurrent requests)Transfer rate: 70.42 receivedConnection Times (ms)minmean[+/-sd] median maxConnect: 0 0 1.9 0 16Processing: 6355188.8 547 859Waiting: 6355188.7 547 859Total: 6355288.8 547 859Percentage of the requests served within a certain time (ms)50% 54766% 56375% 56380% 57890% 60995% 71998% 79799% 828100% 859 (longest request)分析以上关键数据吞吐率Requests per second : 176.31 [#/sec] (mean)请求等待时间Time per request :567.188 (mean)请求处理时间 Time per request :5.672 (mean, across all concurrent requests)6.继续测试-n1000 –c200http://localhost/oop5.phpServer Software: Apache/2.2.11Server Hostname: localhostServer Port: 80Document Path: /oop5.phpDocument Length: 222 bytesConcurrency Level: 200Time taken for tests: 6.047 secondsComplete requests: 1000Failed requests: 0Write errors: 0Total transferred: 409000 bytesHTML transferred: 222000 bytesRequests per second: 165.37 [#/sec] (mean)Time per request: 1209.375 (mean)Time per request: 6.047 (mean, across all concurrent requests)Transfer rate: 66.05 receivedConnection Times (ms)minmean[+/-sd] median maxConnect: 0 0 2.5 0 16Processing: 109 1124 219.8 1188 1438Waiting: 109 1124 219.7 1188 1438Total: 109 1124 219.8 1188 1438Percentage of the requests served within a certain time (ms)50% 118866% 123475% 123480% 123490% 125095% 129798% 137599% 1406100% 1438 (longest request)7.继续测试-n2000 –c200http://localhost/oop5.phpThis is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking localhost (be patient)Completed 200 requestsCompleted 400 requestsCompleted 600 requestsCompleted 800 requestsCompleted 1000 requestsCompleted 1200 requestsCompleted 1400 requestsCompleted 1600 requestsCompleted 1800 requestsCompleted 2000 requestsFinished 2000 requestsServer Software: Apache/2.2.11Server Hostname: localhostServer Port: 80Document Path: /oop5.phpDocument Length: 222 bytesConcurrency Level: 200Time taken for tests: 11.750 secondsComplete requests: 2000Failed requests: 0Write errors: 0Total transferred: 818000 bytesHTML transferred: 444000 bytesRequests per second: 170.21 [#/sec] (mean)Time per request: 1175.000 (mean)Time per request: 5.875 (mean, across all concurrent requests)Transfer rate: 67.99 receivedConnection Times (ms)minmean[+/-sd] median maxConnect: 0 0 2.2 0 16Processing: 109 1134 155.8 1156 1469Waiting: 109 1134 155.8 1156 1469Total: 109 1134 155.8 1156 1469Percentage of the requests served within a certain time (ms)50% 115666% 117275% 118880% 120390% 121995% 123498% 132899% 1406100% 1469 (longest request)8.继续测试 持久连接(Keep-alive) 未启用持久连接模式-n1000 –c100 http://www.zjut.edu.cn/Server Software: Apache-Coyote/1.1Server Hostname: www.zjut.edu.cnServer Port: 80Document Path: /Document Length: 0 bytesConcurrency Level: 100Time taken for tests: 2.094 secondsComplete requests: 1000Failed requests: 0Write errors: 0Non-2xx responses: 1000Total transferred: 294000 bytesHTML transferred: 0 bytesRequests per second: 477.61 [#/sec] (mean)Time per request: 209.375 (mean)Time per request: 2.094 (mean, across all concurrent requests)Transfer rate: 137.13 receivedConnection Times (ms)minmean[+/-sd] median maxConnect: 0 2 5.0 0 16Processing: 019349.9 203 266Waiting: 010963.2 109 250Total: 019550.2 203 266Percentage of the requests served within a certain time (ms)50% 20366% 21975% 21980% 23490% 25095% 25098% 25099% 250100% 266 (longest request)启用持久连接 ab -n1000 -c100 -k http://www.zjut.edu.cn/Server Software: Apache-Coyote/1.1Server Hostname: www.zjut.edu.cnServer Port: 80Document Path: /Document Length: 0 bytesConcurrency Level: 100Time taken for tests: 1.234 secondsComplete requests: 1000Failed requests: 0Write errors: 0Non-2xx responses: 1006Keep-Alive requests: 546Total transferred: 298494 bytesHTML transferred: 0 bytesRequests per second: 810.13 [#/sec] (mean)Time per request: 123.438 (mean)Time per request: 1.234 (mean, across all concurrent requests)Transfer rate: 236.15 receivedConnection Times (ms)minmean[+/-sd] median maxConnect: 0 1 3.6 0 16Processing: 010627.5 94 188Waiting: 0 8537.4 94 188Total: 010727.6 94 188Percentage of the requests served within a certain time (ms)50% 9466% 10975% 12580% 12590% 15695% 15698% 15699% 172100% 188 (longest request)
页:
[1]