ab压测工具
原理:
安装
yum -y install httpd-tools
参数:
[root@VM-2-14-centos ~]# ab --helpab: wrong number of argumentsUsage: ab [options] [http[s]://]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 benchmarkingThis implies -n 50000 ##用于测试的最大秒数,等价于 -n 等于50000-s timeout Seconds to max. wait for each responseDefault is 30 seconds ##等待每个响应的最长秒数,默认值为30秒-b windowsize Size of TCP send/receive buffer, in bytes ##TCP发送/接收缓存区的大小(字节)-B address Address to bind to when making outgoing connections ##建立传出连接时要绑定的地址-p postfile File containing data to POST. Remember also to set -T ##包含POST数据的文件。还需要设置-T-u putfile File containing data to PUT. Remember also to set -T ##包含PUT数据的文件,还需要设置-T-T content-type Content-type header to use for POST/PUT data, eg.'application/x-www-form-urlencoded'Default is 'text/plain' ## 用于POST/PUT数据的内容类型头。-v verbosity How much troubleshooting info to print ##设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。-w Print out results in HTML tables 以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表-i Use HEAD instead of GET ##执行HEAD请求,而不是GET-x attributes String to insert as table attributes ##设置<table>属性的字符串。-y attributes String to insert as tr attributes ##设置<tr>属性的字符串。-z attributes String to insert as td or th attributes ##设置<td>属性的字符串。-C attribute Add cookie, eg. 'Apache=1234'. (repeatable) ##对请求附加一个Cookie行。其典型形式是name=value的一个参数对。此参数可以重复。-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. ##对服务器提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。-P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password. ##对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送-X proxy:port Proxyserver and port number to use ##对请求使用代理服务器。-V Print version number and exit ##显示版本号并退出。-k Use HTTP KeepAlive feature ##启用HTTP KeepAlive功能,即, 在一个HTTP会话中执行多个请求。默认时,不启用KeepAlive功能。-d Do not show percentiles served table. ##显示”percentage served within XX [ms] table”的消息(为以前的版本提供支持)。-S Do not show confidence estimators and warnings. ##不显示中值和标准背离值, 而且在均值和中值为标准背离值的1到2倍时,也不显示警告或出错信息。默认时,会显示 最小值/均值/最大值等数值。(为以前的版本提供支持)。-q Do not show progress when doing more than 150 requests ##如果处理的请求数大于150, ab每处理大约10%或者100个请求时,会在stderr输出一个进度计数。此-q标记可以抑制这些信息。-l Accept variable document length (use this for dynamic pages) ##接受可变文档长度(用于动态页面)-g filename Output collected data to gnuplot format file. ##把所有测试结果写入一个’gnuplot’或者TSV (以Tab分隔的)文件。此文件可以方便地导入到Gnuplot, IDL, Mathematica, Igor甚至Excel中。其中的第一行为标题。-e filename Output CSV file with percentages served ##产生一个以逗号分隔的(CSV)文件, 其中包含了处理每个相应百分比的请求所需要(从1%到100%)的相应百分比的(以微妙为单位)时间。由于这种格式已经“二进制化”,所以比’gnuplot’格式更有用。-r Don't exit on socket receive errors. ##套接字接收错误时不退出。-m method Method name ##方法名称-h Display usage information (this message) ##显示使用方法。-I Disable TLS Server Name Indication (SNI) extension ##禁用TLS服务器名称指示(SNI)扩展-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) ##指定SSL/TLS密码套件。-f protocol Specify SSL/TLS protocol (SSL2, TLS1, TLS1.1, TLS1.2 or ALL) ##指定SSL/TLS协议(SSL2、TLS1、TLS1.1、TLS1.2或ALL)-E certfile Specify optional client certificate chain and private key ##指定可选的客户端证书链和私钥
压测返回结果解析
ab -c 1 -n 10000 https://xxx.cn/q.php/bbs.topic.105510.html
host之后必须有”/“,表示此目录而不是此文件;


版权声明:本文内容始发于CSDN>作者: 惋安,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行可。始发链接:https://blog.csdn.net/Loners_fan/article/details/127890332在此特别鸣谢原作者的创作。此篇文章的所有版权归原作者所有,商业转载建议请联系原作者,非商业转载请注明出处
文章转载自巴韭特锁螺丝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




