Apache-ab 接口性能测试

Apache-ab

URL:https://httpd.apache.org/docs/2.4/programs/ab.html

注:ab工具放在Apache HTTP Server安装包的bin目录下,所以要先安装Apache HTTP Server(以Windows系统为例)。

到Apache HTTP Server官网下载页面(点击链接),目前最新的版本不提供Windows系统下的安装包,所以用第三方的安装包。

安装步骤:

1、点击:http://httpd.apache.org/download.cgi#apache24

2、点击:Files for Microsoft Windows,再点击:ApacheHaus

3、选择自己的对应的版本下载;

4、选择自己的路径解压,找到bin目录,在cmd.exe执行ab

附-使用简介:

使用:

ab [ -A auth-username:password ] [ -b windowsize ] [ -B local-address ] [ -c concurrency ] [ -C cookie-name=value ] [ -d ] [ -e csv-file ] [ -f protocol ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [ -i ] [ -k ] [ -l ] [ -m HTTP-method ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ] [ -r ] [ -s timeout ] [ -S ] [ -t timelimit ] [ -T content-type ] [ -u PUT-file ] [ -v verbosity] [ -V ] [ -w ] [ -x -attributes ] [ -X proxy[:port] ] [ -y -attributes ] [ -z-attributes ] [ -Z ciphersuite ] [http[s]://]hostname[:port]/path

常用参数说明:

-n    请求的总数,默认是1次。

-c    并发数,同一时间请求数。

-p    如果后面接的是文件,表示POST请求,文件中包含请求数据,根据数据格式,设置-T参数。

-T    设置请求头中的Content-type(针对POST/PUT),比如:application/x-www-form-urlencoded。默认是text/plain。

-w    将测试结果打印到HTML表格中。

举例:

解释:

键入命令: 
ab -n 10 -c 10 URL
(-n发出10个请求,-c模拟10并发,相当10人同时访问,后面是测试url)

ab -t 1 -c 100 URL
在1秒内发请求,一次100个请求。 

注:输入报错,不支持ab的用abs

猜你喜欢

转载自blog.csdn.net/fengyupotest/article/details/89849473