使用Apache ab进行http性能测试
Mac自带了Apache环境
打开“终端(terminal)”,输入sudoapachectl-v,(可能需要输入机器秘密)。如下显示Apache的版本
接着输入sudoapachectlstart,这样Apache就启动了。打开Safari浏览器地址栏输入“http://localhost”,可以看到内容为“Itworks!”的页面。其位于“/Library(资源库)/WebServer/Documents/”下,这就是Apache的默认根目录。
Apache的安装目录在:/etc/apache2/,etc默认是隐藏的。有三种方式查看:
1、dock下右键Finder,选择"前往文件夹",输入"/etc"
2、在finder下----》前往---》前往文件夹,然后输入/etc
3、可以在terminal输入"open/etc"
windows可以去http://httpd.apache.org/download.cgi下载,或者从命令行安装
1.安装apache
sudoportinstallapache2
启动apache:sudoapachectlstart
2. brewinstallpcre
3.wgethttp://ftp.yz.yamagata-u.ac.jp/pub/network/apache//httpd/httpd-2.4.4.tar.bz2
(1)解压
(2)./configure
(3)make&&makeinstall
(4)sudocpsupport/ab/usr/sbin
4.ab-n1000-c10http://localhost:3000/ 最后这个斜杠不能少
这个ab-n1000-c10http://localhost:3000/命令,在window系统下,需要先用cd命令定位到你的apache安装目录的bin文件夹。。。
ab的参数说明
-n 需要执行的请求次数
-c 并发的数量
-t 等待返回的最长时间
-b TCP收发缓冲区的大小,单位(byte)
-p使用post(同时需要定义-T参数)
-u使用put(同时需要定义-T参数)
-Tcontent-type,例如application/x-www-form-urlencoded,默认为text/plain
-w把结果打印在html的表格里
-x 表格的属性
-y tr行属性
-z td列属性
-C设置cookie例如Apach=1234
-Hheader行,例如Accept-Encoding:gzip
-k是否标示位HTTPKeepAlive
测试结果:
ThisisApacheBench,Version2.3<$Revision:1663405$> Copyright1996AdamTwiss,ZeusTechnologyLtd,http://www.zeustech.net/ LicensedtoTheApacheSoftwareFoundation,http://www.apache.org/ Benchmarkinglocalhost(bepatient) Completed100requests Completed200requests Completed300requests Completed400requests Completed500requests Completed600requests Completed700requests Completed800requests Completed900requests Completed1000requests Finished1000requests ServerSoftware: ServerHostname:localhost ServerPort:3000 DocumentPath:/ DocumentLength:14bytes ConcurrencyLevel:10 Timetakenfortests:0.323seconds Completerequests:1000 Failedrequests:0 Totaltransferred:115000bytes HTMLtransferred:14000bytes Requestspersecond:3097.37[#/sec](mean) Timeperrequest:3.229[ms](mean) Timeperrequest:0.323[ms](mean,acrossallconcurrentrequests) Transferrate:347.85[Kbytes/sec]received ConnectionTimes(ms) minmean[+/-sd]medianmax Connect:000.101 Processing:132.2216 Waiting:132.2216 Total:132.2216 Percentageoftherequestsservedwithinacertaintime(ms) 50%2 66%3 75%3 80%4 90%5 95%7 98%13 99%15 100%16(longestrequest)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。