ab性能测试
AB(ApacheBench) 是 Apache 自带的超文本传输协议 (HTTP) 性能测试工具。 其设计意图是描绘当前所安装的 Apache 的执行性能, 主要是显示 Apache 每秒可以处理多少个请求。
1.http请求
ab -n30000 -c1000 "http://10.1.1.21:8080/"
2.ab 测试 http 接口 (POST)
ab -n400 -c20 -p "img.json" -T "application/x-www-form-urlencoded" "http://10.1.1.21:8080/test.do"
3.img.json 为符合接口格式的字符串
MIME 类型 application/x-www-form-urlencoded 与 multipart/form-data 和 text/plain 参考
类似于 curl,curl 指定 post 请 @ 指定文件
curl "http://10.1.1.21:8080/test.do" -d @/root/img.json
4.ab 测试 webservice 接口
ab -k -T "Content-Type:text/xml;charset=UTF-8" -p data.xml -n 1000 -c 32 http://10.1.1.21:8080/services/routeService?wsdl
注意:data.xml 必须符合 wsdl 规范,可以使用 soapUI 生成
如果报错:no soapaction header
ab -k -T "Content-Type:text/xml;charset=UTF-8;soapaction=''" -p data.xml -n 1000 -c 32 http://10.1.1.21:8080/services/routeService?wsdl
查看帮助:
[root@localhost local]# ab --help ab: wrong number of arguments Usage: ab [options] [http[s]://]hostname[:port]/path Options are: -n requests Number of requests to perform 总请求数 -c concurrency Number of multiple requests to make 并发数 -t timelimit Seconds to max. wait for responses -b windowsize Size of TCP send/receive buffer, in bytes -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 for POSTing, 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. -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. -h Display usage information (this message) -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) -f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL) You have new mail in /var/spool/mail/root

浙公网安备 33010602011771号