压力测试工具之ab
来源:互联网 发布:人工蜂群算法 工具箱 编辑:程序博客网 时间:2024/05/22 16:49
1 ab命令原理
Apache的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx、lighthttp、IIS等其它Web服务器的压力。
ab命令对发出负载的计算机要求很低,既不会占用很多CPU,也不会占用太多的内存,但却会给目标服务器造成巨大的负载,因此是某些DDOS攻击之必备良药,老少皆宜。自己使用也须谨慎。否则一次上太多的负载,造成目标服务器直接因内存耗光死机,而不得不硬重启,得不偿失。
在带宽不足的情况下,最好是本机进行测试,建议使用内网的另一台或者多台服务器通过内网进行测试,这样得出的数据,准确度会高很多。远程对web服务器进行压力测试,往往效果不理想(因为网络延时过大或带宽不足)
2 运行
A 100个并发,总请求数 500
ab -c 100 -n 500 http://127.0.0.1/phpinfo.phpThis is ApacheBench, Version 2.3 <$Revision: 1604373 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsFinished 500 requestsServer Software: Apache/2.4.10Server Hostname: 127.0.0.1Server Port: 80Document Path: /phpinfo.phpDocument Length: 66005 bytes HTTP响应数据的正文长度Concurrency Level: 100Time taken for tests: 1.759 secondsComplete requests: 500Failed requests: 78 (Connect: 0, Receive: 0, Length: 78, Exceptions: 0)Total transferred: 33096996 bytesHTML transferred: 33002496 bytesRequests per second: 284.30 [#/sec] (mean)Time per request: 351.739 [ms] (mean)Time per request: 3.517 [ms] (mean, across all concurrent requests)Transfer rate: 18377.98 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 0 0.8 0 12Processing: 3 316 447.9 112 1423Waiting: 1 311 449.2 100 1423Total: 3 316 448.0 112 1435Percentage of the requests served within a certain time (ms) 50% 112 66% 260 75% 276 80% 345 90% 1236 95% 1297 98% 1339 99% 1358 100% 1435 (longest request)
B 在60秒内发请求,一次100个请求。
ab -c 100 -t 60 http://127.0.0.1/phpinfo.phpThis is ApacheBench, Version 2.3 <$Revision: 1604373 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 127.0.0.1 (be patient)Completed 5000 requestsCompleted 10000 requestsFinished 10525 requestsServer Software: Apache/2.4.10Server Hostname: 127.0.0.1Server Port: 80Document Path: /phpinfo.phpDocument Length: 66005 bytesConcurrency Level: 100Time taken for tests: 60.000 secondsComplete requests: 10525Failed requests: 1115 (Connect: 0, Receive: 0, Length: 1115, Exceptions: 0)Total transferred: 696690603 bytesHTML transferred: 694701378 bytesRequests per second: 175.42 [#/sec] (mean)Time per request: 570.076 [ms] (mean)Time per request: 5.701 [ms] (mean, across all concurrent requests)Transfer rate: 11339.28 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 0 0.9 0 34Processing: 0 567 1689.7 273 18692Waiting: 0 561 1689.3 270 18692Total: 0 567 1689.7 274 18693Percentage of the requests served within a certain time (ms) 50% 273 66% 295 75% 338 80% 401 90% 657 95% 1305 98% 4499 99% 7287 100% 18693 (longest request)
C 在url中带参数,p.txt 是和ab.exe在一个目录,p.txt 中可以写参数,如 p=wdp&fq=78
ab -t 60 -c 100 -T "text/plain" -p p.txt http://127.0.0.1/phpinfo.php
3 帮助
ab -hUsage: 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)
0 0
- 压力测试工具之ab
- web压力测试工具之ab
- apache压力测试之ab工具
- 压力测试工具ab
- 压力测试工具ab
- ab压力测试工具
- ab工具压力测试
- ab压力测试工具
- 压力测试工具 ab
- apache 压力测试工具ab
- apache 压力测试工具ab
- apache 压力测试工具ab
- apache压力测试工具ab
- apache 压力测试工具ab
- apache 压力测试工具ab
- 压力测试工具Ab简介
- ApacheBench(ab)压力测试工具
- ab.exe 压力测试工具
- 2016.11.30
- Java——基本运算符一些重要的点
- 用shell脚本操作数据库
- 使用MemoryStream类读写内存
- 查看linux版本
- 压力测试工具之ab
- Altium Designer隐藏或显示元件名字
- JNI开发 NDK integration is deprecated in the current plugin
- 2016.12.1
- yarn 命令学习:yarn application
- C 结构体 struct 详解
- Activity的启动模式
- NYOJ 迷宫寻宝(一) bfs
- hadoop+HBase+Zookeeper 安装