博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Apache Server 的ab进行web请求压力测试
阅读量:4306 次
发布时间:2019-06-06

本文共 3027 字,大约阅读时间需要 10 分钟。

参考:http://www.cnblogs.com/spring3mvc/archive/2010/11/23/2414741.html

自己写代码经常是顺着逻辑写下去,写完后run一下,ok就玩完事了。直到遇到一个又一个的问题的时候才回头过来重新修改。这就是没有测试的悲剧。因此,在今后的代码中一定要尝试着去写测试,去做测试。

发现Apache Server下有个工具ab可以进行并发请求,正好有个需求想要知道并发下的访问情况。

1.下载

访问:http://httpd.apache.org/download.cgi

然后点击:

 

然后跳到一个页面说只提供源码,自己编译,云彩。不过也提供了推荐第三方编译,选择第一个:

然后是选择镜像和版本,不要选择德国的:

 

2.安装

我这是买椟还珠的游戏,不想去了解Apache的功能,只想要ab。所以直接解压,然后在bin目录找到ab就可以了:

 

3.测试

输入ab就可以看到帮助文档

D:\Java\httpd-2.4.23-x64-vc14\Apache24\bin>abab: wrong number of argumentsUsage: ab [options] [http://]hostname[:port]/pathOptions are:    -n requests     Number of requests to perform    -c concurrency  Number of multiple requests to make at a time    -t timelimit    Seconds to max. to spend on benchmarking                    This implies -n 50000    -s timeout      Seconds to max. wait for each response                    Default is 30 seconds    -b windowsize   Size of TCP send/receive buffer, in bytes    -B address      Address to bind to when making outgoing connections    -p postfile     File containing data to POST. Remember also to set -T    -u putfile      File containing data to PUT. Remember also to set -T    -T content-type Content-type header to use for POST/PUT data, 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.    -q              Do not show progress when doing more than 150 requests    -l              Accept variable document length (use this for dynamic pages)    -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.    -m method       Method name    -h              Display usage information (this message)D:\Java\httpd-2.4.23-x64-vc14\Apache24\bin>
View Code

 

举例:

D:\Java\httpd-2.4.23-x64-vc14\Apache24\bin>ab -n 20 -c 10 localhost:8080/user/all

-n表示一共请求20次

-c表示并发量为10次。

也就是说,会进行两个并发,每次10个。

 

转载于:https://www.cnblogs.com/woshimrf/p/5678348.html

你可能感兴趣的文章
openstack报错解决一
查看>>
openstack报错解决二
查看>>
linux source命令
查看>>
openstack报错解决三
查看>>
乙未年年终总结
查看>>
子网掩码
查看>>
第一天上班没精神
查看>>
启动eclipse报错:Failed to load the JNI shared library
查看>>
eclipse安装插件的两种方式在线和离线
查看>>
linux下源的相关笔记(suse)
查看>>
linux系统分区文件系统划分札记
查看>>
Linux(SUSE 12)安装Tomcat
查看>>
Linux(SUSE 12)安装jboss4并实现远程访问
查看>>
Neutron在给虚拟机分配网络时,底层是如何实现的?
查看>>
netfilter/iptables全攻略
查看>>
Overlay之VXLAN架构
查看>>
Eclipse : An error occurred while filtering resources(Maven错误提示)
查看>>
在eclipse上用tomcat部署项目404解决方案
查看>>
web.xml 配置中classpath: 与classpath*:的区别
查看>>
suse如何修改ssh端口为2222?
查看>>