ab是apache自带的网站压力测试工具,使用起来非常的简单和方便,不仅仅是可以apache服务器进行网站访问压力测试,还可以对其他类型的服务器进行压力测试,比如nginx,tomcat,iis等,可以根据需要安装。
一:安装
首先当然是下载安装了。
在这里只讲window下在下载安装
官方下载地址:,(https://www.apachehaus.com/cgi-bin/download.plx)
下载完成后解压
我就直接解压到d盘的apacheab中去了
修改解压根目录下的conf/httpd.conf文件的端口配置,默认是80端口,应该是被占用了,无法安装,可以自行修改为其他,我在这里修改为8088端口
文件解压到本地文件夹下,如果不是解压在c盘,需要设置参数:
我的解压到了d盘下,需要设置参数,conf->httpd.conf 使用文本编辑器打开,
需要修改的有三个地方:
开始测试
如果你需要在命令行的任意路径下可以输入ab测试,可以把bin目录路径加到环境变量的path中去
我是在bin目录下打开命令行的
注意,需要在域名后加上/path
ab -n 100 -c 10 http://www.baidu.com/s
-n 表示请求数,-c 表示并发数.
s为path,表示指定测试地址,不指定可能会报ab: invalid url 错误.
另外还有-t 表示多少s内并发和请求
测试出来的数据如下:
d:\apacheab\apache24\bin>ab -n 100 -c 10 http://www.baidu.com/sthis is apachebench, version 2.3 <$revision: 1807734 $> copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/licensed to the apache software foundation, http://www.apache.org/ benchmarking www.baidu.com (be patient).....done
server software: bws/1.1 ##服务器软件和版本
server hostname: www.baidu.com
##请求的地址/域名
server port: 80 ##端口
document path: /s
##请求的路径
document length: 112435 bytes
##页面数据/返回的数据量
concurrency level: 10 ##并发数
time taken for tests: 4.764 seconds
##共使用了多少时间
complete requests: 100 ##请求数
failed requests: 99 ##失败请求 百度为什么失败这么多,应该是百度做了防范
(connect: 0, receive: 0, length: 99, exceptions: 0)
total transferred: 11342771 bytes
##总共传输字节数,包含http的头信息等
html transferred: 11247622 bytes
##html字节数,实际的页面传递字节数
requests per second: 20.99 [#/sec] (mean)
##每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量
time per request: 476.427 [ms] (mean)
##用户平均请求等待时间
time per request: 47.643 [ms] (mean, across all concurrent requests)
##服务器平均处理时间,也就是服务器吞吐量的倒数
transfer rate: 2325.00 [kbytes/sec] received
##每秒获取的数据长度
connection times (ms)
min mean[+/-sd] median max
connect: 22 41 12.4 39 82##连接的最小时间,平均值,中值,最大值
processing: 113 386 211.1 330 1246##处理时间
waiting: 25 80 43.9 73 266##等待时间
total: 152 427 210.1 373 1283##合计时间
percentage of the requests served within a certain time (ms) 50% 373 ## 50%的请求在373ms内返回
66% 400 ## 60%的请求在400ms内返回
75% 426
80% 465
90% 761
95% 930
98% 1192
99% 1283
100% 1283 (longest request)
因为ab工具消耗小,所以有些人也用来进行ddos攻击,算一种ddos攻击工具
更多apache的相关技术文章,请访问apache教程栏目进行学习!
以上就是apache上的ab需要安装么的详细内容。
