压力测试工具ab及centos下单独安装方法 nginx和tomcat静态资源的性能测试
Apache安装包中自带的压力测试工具Apache Benchmark(简称ab)简单易用,这里采用ab作为压国测试工具.
独立安装:
ab运行需要信赖apr-util包:
# yum install apr-util
安装信赖yum-utils中的yumdownload工具如果没有找到yumdownload
# yum install yum-utils
安装完成执行以下指令
[root@localhost opt]# cd /opt/ [root@localhost opt]# mkdir abtmp [root@localhost opt]# cd abtmp/ [root@localhost abtmp]# yum install yum-utils.noarch
[root@localhost abtmp]# yumdownloader httpd-tools* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn httpd-tools-2.4.6-45.el7.centos.4.x8 | 84 kB 00:00 [root@localhost abtmp]# ls httpd-tools-2.4.6-45.el7.centos.4.x86_64.rpm
安装:
[root@localhost abtmp]# rpm -ihv httpd-tools-2.4.6-45.el7.centos.4.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:httpd-tools-2.4.6-45.el7.centos.4 ################################# [100%]
下面对NGINX做测试:
# ab -n 1000 -c100 123.57.36.227/index.html This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 123.57.36.227 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests #处理1000个请求 Server Software: nginx/1.6.2 Server Hostname: 123.57.36.227 Server Port: 80 Document Path: /index.html Document Length: 13 bytes #与Tomcat请求页面的节数大小一致 Concurrency Level: 100 Time taken for tests: 2.539 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 242000 bytes HTML transferred: 13000 bytes Requests per second: 393.82 [#/sec] (mean)#吞吐量:393.82/s Time per request: 253.920 [ms] (mean)#每个请求的平均处理时间 Time per request: 2.539 [ms] (mean, across all concurrent requests) Transfer rate: 93.07 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 110 308.8 4 1144 Processing: 2 76 126.9 4 619 Waiting: 2 76 126.9 4 619 Total: 5 186 337.1 9 1624 Percentage of the requests served within a certain time (ms) 50% 9 66% 211 75% 212 80% 213#80%的请求在213ms之内完成 90% 1007 95% 1010 98% 1213 99% 1214 100% 1624 (longest request)#1624ms完成100%的请求
下面对tomcat做测试:
# ab -n 1000 -c100 123.57.36.227:8080/index.jsp This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 123.57.36.227 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests # Server Software: Apache-Coyote/1.1 Server Hostname: 123.57.36.227 Server Port: 8080 Document Path: /index.jsp Document Length: 13 bytes Concurrency Level: 100 Time taken for tests: 4.101 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 254000 bytes HTML transferred: 13000 bytes Requests per second: 243.84 [#/sec] (mean) Time per request: 410.111 [ms] (mean) Time per request: 4.101 [ms] (mean, across all concurrent requests) Transfer rate: 60.48 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 46 201.0 4 1007 Processing: 3 266 610.4 68 3232 Waiting: 3 255 609.2 57 3232 Total: 6 312 628.6 83 3238 Percentage of the requests served within a certain time (ms) 50% 83 66% 149 75% 217 80% 295 90% 1010 95% 1449 98% 3164 99% 3191 100% 3238 (longest request)
对比两数值除理1000个请求tomcat所用的时间是nginx的(3238/1624=1.99)2倍时间!
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维