设为首页 收藏本站
查看: 963|回复: 0

[经验分享] 服务器并发能力测试 Apache Beach

[复制链接]

尚未签到

发表于 2015-8-2 10:20:53 | 显示全部楼层 |阅读模式
1.打开windows cmd(以下数据兼为windows xp平台运行数据)2.Cd 至Apache bin目录。3.运行ab.exe  ( ApacheBench command line utility)Java代码  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   -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 [options] [http://]hostname[:port]/pathOptions 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-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 [ms] (mean)  用户平均请求等待时间Time per request:       5.125 [ms] (mean, across all concurrent requests) 服务器平均处理请求时间 Transfer rate:          77.93 [Kbytes/sec] received  表示请求在单位时间内从服务器获取的数据长度Connection Times (ms)min  mean[+/-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 [ms] (mean)请求处理时间 Time per request :5.125 [ms] (mean, across all concurrent requests)5. 继续测试  -n1000 -c100  http://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 [ms] (mean)Time per request:       5.672 [ms] (mean, across all concurrent requests)Transfer rate:          70.42 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   maxConnect:        0    0   1.9      0      16Processing:    63  551  88.8    547     859Waiting:       63  551  88.7    547     859Total:         63  552  88.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 [ms] (mean)请求处理时间 Time per request :5.672 [ms] (mean, across all concurrent requests)6.继续测试  -n1000 –c200  http://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 [ms] (mean)Time per request:       6.047 [ms] (mean, across all concurrent requests)Transfer rate:          66.05 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-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 –c200  http://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 [ms] (mean)Time per request:       5.875 [ms] (mean, across all concurrent requests)Transfer rate:          67.99 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-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 [ms] (mean)Time per request:       2.094 [ms] (mean, across all concurrent requests)Transfer rate:          137.13 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   maxConnect:        0    2   5.0      0      16Processing:     0  193  49.9    203     266Waiting:        0  109  63.2    109     250Total:          0  195  50.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 [ms] (mean)Time per request:       1.234 [ms] (mean, across all concurrent requests)Transfer rate:          236.15 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   maxConnect:        0    1   3.6      0      16Processing:     0  106  27.5     94     188Waiting:        0   85  37.4     94     188Total:          0  107  27.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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-93232-1-1.html 上篇帖子: Windows下Apache 2.0.45+Tomcat 5.0.28整合 下篇帖子: Apache的虚拟主机设置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表