AB压力测试工具安装及测试
ab全称为:apache bench
查看ab是否安装成功,使用ab –V命令进行检测。如下:
ab是Apache超文本传输协议(HTTP)的性能测试工具。其设计意图是描绘当前所安装的Apache的执行性能,主要是显示你安装的Apache每秒可以处理多少个请求。也可以用来测试nginx、lighthttp、tomcat、IIS等其它Web服务器的压力负载性能。centos下面,ab的安装很简单,安装Apache会自动安装,如果要单独安装ab,可以使用yum安装:
yum -y install httpd-tools
-
ab -V 输出信息大概如下
-
ab参数说明 有关ab命令的使用,我们可以通过帮助命令进行查看。如下: ab --help参数很多,一般我们用 -c 和 -n 参数就可以了。 #ab -c 1000 -n 4000 http://www.yousite.com/index.html #具体到某页面,特别注意这里一定要具体到某一个页面哦,不能是http://www.baidu.com,这样会提示该地址找不到的情况,必须加上参数。 -n后面的4000代表总共发出4000个请求;-c后面的1000表示采用1000个并发(模拟1000个人同时访问),后面的网址表示测试的目标URL。
主要介绍里面的几个指标,我基本也就看这几个指标,简单测试足够了,如果要全面的监控nginx,需要用到专业的监控程序,如nagios[root@Tomcat ab]# ab -c 1000 -n 4000 http://192.168.0.222/docs/manager-howto.html This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.0.222 (be patient) Completed 400 requests Completed 800 requests Completed 1200 requests Completed 1600 requests Completed 2000 requests Completed 2400 requests Completed 2800 requests Completed 3200 requests Completed 3600 requests Finished 4000 requests Server Software: nginx/1.4.3 Server Hostname: 192.168.0.222 Server Port: 80 Document Path: /docs/manager-howto.html Document Length: 73924 bytes Concurrency Level: 1000 Time taken for tests: 0.875928 seconds Complete requests: 4000 Failed requests: 0 Write errors: 0 Total transferred: 296732000 bytes HTML transferred: 295696000 bytes Requests per second: 4566.59 [#/sec] (mean) #最重要的指标之一,相当于LR中的每秒事务数,后面括号中的mean表示这是一个平均值,越大抗压越强 Time per request: 218.982 [ms] (mean) #最重要的指标之二,相当于LR中的平均事务响应时间,后面括号中的mean表示这是一个平均值 Time per request: 0.219 [ms] (mean, across all concurrent requests) Transfer rate: 330822.86 [Kbytes/sec] received #平均每秒网络上的流量,吞吐量,越大抗压越强 Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 4.5 0 29 Processing: 1 17 14.5 17 653 Waiting: 0 17 14.5 17 653 Total: 15 18 15.2 17 674 Percentage of the requests served within a certain time (ms) 50% 17 66% 18 75% 18 80% 18 90% 20 95% 22 98% 37 99% 40 100% 674 (longest request)