ab
的全称是
ApacheBench
,
是
Apache
附带的一个小工具
,
专门用于
HTTP Server
的
benchmark testing
,
可以同时模拟多个并发请求。一般开发人员在进行真正的压力测试之前可以使用这个工具来进行自测,从而更好地掌握性能。
ab的参数有:
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
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-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
-h Display usage information (this message)
首先进入安装Apache下的bin目录,比如在我本机就是C:\Program Files\Apache Software Foundation\Apache2.2\bin,较常用的参数是n和c,运行命令和结果如下:
C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 10000 -c 100 http://renmai-dev.china.alibaba.com/view/attention/index/1.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking renmai-dev.china.alibaba.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: renmai-dev.china.alibaba.com
Server Port: 80
Document Path: /view/attention/index/1.html
Document Length: 0 bytes
Concurrency Level: 100
Time taken for tests: 17.812500 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10000
Total transferred: 10130006 bytes
HTML transferred: 0 bytes
Requests per second: 561.40 [#/sec] (mean)
Time per request: 178.125 [ms] (mean)
Time per request: 1.781 [ms] (mean, across all concurrent requests)
Transfer rate: 555.34 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.8 0 31
Processing: 15 176 101.5 140 1125
Waiting: 15 176 101.3 140 1125
Total: 15 177 101.5 140 1125
Percentage of the requests served within a certain time (ms)
50% 140
66% 156
75% 171
80% 171
90% 281
95% 421
98% 484
99% 609
100% 1125 (longest request)
请注意并发数最大为1024,取值不可大于此。接下来,比较一下压力更大的情况。
C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 1000000 -c 1000 http://renmai-dev.china.alibaba.com/view/attention/index/1.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking renmai-dev.china.alibaba.com (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Finished 1000000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: renmai-dev.china.alibaba.com
Server Port: 80
Document Path: /view/attention/index/1.html
Document Length: 0 bytes
Concurrency Level: 1000
Time taken for tests: 1484.622112 seconds
Complete requests: 1000000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000000
Total transferred: 1012951156 bytes
HTML transferred: 0 bytes
Requests per second: 673.57 [#/sec] (mean)
Time per request: 1484.622 [ms] (mean)
Time per request: 1.485 [ms] (mean, across all concurrent requests)
Transfer rate: 666.30 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 18.3 0 968
Processing: 140 1477 454.2 1421 3890
Waiting: 0 885 501.5 828 3156
Total: 140 1478 454.7 1421 3890
Percentage of the requests served within a certain time (ms)
50% 1421
66% 1687
75% 1796
80% 1859
90% 2078
95% 2296
98% 2499
99% 2734
100% 3890 (longest request)
可以看到,随着并发数的增多,实际性能将所有下降。
Apache
下载页:
http://httpd.apache.org/download.cgi
更多信息:
http://httpd.apache.org/docs/2.0/programs/ab.html
参数的中文介绍可参照: http://mayer.iteye.com/blog/176604
分享到:
相关推荐
ApacheBench(压力测试).很好的教程 做好人了
ApacheBench压力测试工具,配合使用文档使用,凑字凑字凑字
Windows下的ApacheBench。网站压力测试神器。
ab 的全称是 ApacheBench , 是 Apache 附带的一个小工具 , 专门用于 HTTP Server 的 benchmark testing , 可以同时模拟多个并发请求。
ApacheBench测试,ab.exe纯文件,省去配置apache麻烦。
apache2.2+centos6.4 64位环境下编译 用之前需要安装 apr和apr-util依赖包
NULL 博文链接:https://sosuny.iteye.com/blog/588644
ApacheBench1.0.zipApacheBench1.0.zip
NULL 博文链接:https://fangpeng123456789.iteye.com/blog/1396798
ApacheBench 是 Apache 服务器自带的一个web压力测试工具,简称ab。ab又是一个命令行工具,对发起负载的本机要求很低,根据ab命令可以创建很多的并发访问线程,模拟多个访问者同时对某一URL地址进行访问,因此可以...
ApacheBench阿帕奇自带的压力测试工具
一、Apache Bench简介 ApacheBench 是 Apache 服务器自带的一个web压力测试工具,简称ab。ab又是一个命令行工具,对发起负载的本机要求很低,根据ab命令可以创建很多的并发访问线程,模拟多个访问者同时对某一URL...
apache压力测试,下载压缩包后,直接解压到目录,使用简单方便快捷
替代ApacheBench (ab)的HTTP负载生成器
主要介绍了CentOS环境下单独安装apachebench的方法,分析了apachebench的安装步骤与相关注意事项,需要的朋友可以参考下
ApacheBench命令原理: ab命令会创建很多的并发访问线程,模拟多个访问者同时对某一URL地址进行访问。它的测试目标是基于URL的,因此,既可以用来测试Apache的负载压力,也可以测试nginx、lighthttp、tomcat...
主要介绍了压力测试工具Apache Bench实现原理及用法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下