首页 > 代码库 > ubuntu下 使用AB做压力测试
ubuntu下 使用AB做压力测试
1最近刚开始接触apache大数据下数据优化,讲一下apache 下ab压力测试工具。
程序“ab”尚未安装。 您可以使用以下命令安装:
apt-get install apache2-utils
以下是ab --help
sage: 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 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. -h Display usage information (this message) -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) -f protocol Specify SSL/TLS protocol (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)
-n :总共的请求执行数,缺省是1; -c: 并发数,缺省是1; -t:测试所进行的总时间,秒为单位,缺省50000s -p:POST时的数据文件 -w: 以HTML表的格式输出结果
以下为执行 ab -n 5000 -c 200 http://localhost/test.php 的结果:
Benchmarking localhost (be patient)Completed 500 requestsCompleted 1000 requestsCompleted 1500 requestsCompleted 2000 requestsCompleted 2500 requestsCompleted 3000 requestsCompleted 3500 requestsCompleted 4000 requestsCompleted 4500 requestsCompleted 5000 requestsFinished 5000 requests //执行完的请求次数
Server Software: Apache/2.4.3 //apache版本Server Hostname: localhost //主机 Server Port: 80 //端口Document Path: /test.php //路径Document Length: 62492 bytes Concurrency Level: 200Time taken for tests: 3.927 seconds //完成此次请求时间Complete requests: 5000 //完成请求次数Failed requests: 527 //失败的请求次数 (Connect: 0, Receive: 0, Length: 527, Exceptions: 0)Total transferred: 313289422 bytes //总共传输字节HTML transferred: 312459422 bytesRequests per second: 1273.33 [#/sec] (mean) //每秒请求次数Time per request: 157.069 [ms] (mean) //一次请求时间Time per request: 0.785 [ms] (mean, across all concurrent requests)Transfer rate: 77914.14 [Kbytes/sec] received //传输速率Connection Times (ms) min mean[+/-sd] median maxConnect: 0 6 73.1 0 1001Processing: 2 150 143.9 111 1626Waiting: 2 137 135.3 103 1197Total: 2 155 160.3 111 1626Percentage of the requests served within a certain time (ms) 50% 111 66% 141 75% 168 80% 191 90% 310 95% 452 98% 673 99% 951 100% 1626 (longest request)
ubuntu下 使用AB做压力测试
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。