推荐:Apache 压力测试工具ab
上一篇 / 下一篇 2016-03-29 19:06:25 / 个人分类:测试工具
51Testing软件测试网'[q/xjC/l$q+w51Testing软件测试网 jd0_QFF关于压力测试,很多同学只知道LR、jmeter
?'y,HQK0在 Apache 有个叫 ab(ApacheBench) 的程序, 此程序是专门用在做压力测试用的软件. ApacheBench(ab) 用来测试 apache 执行效率,可以用来测试网站的压力工具.
RDJ1w1e;D/m0ab 参数51Testing软件测试网4vK*I0{$}dQW#y6R'Hp
ab 参数:
L(p:Le8S-A/i0Usage: /usr/sbin/ab [options] [http[s]://]hostname[:port]/path
6j5z,I_lA_Qn ^0Options are:
/C8f/C4q.?'M0§ -n requests Number of requests to perform
|M1mMo3I,j0§ -c concurrency Number of multiple requests to make51Testing软件测试网/y z}:EM(v;l'x
§ -t timelimit Seconds to max. wait for responses51Testing软件测试网:C^ \!GM"T-m~0R
§ -p postfile File containg data to POST
Hf4Co:{hU\[l0§ -T content-type Content-type header for POSTing51Testing软件测试网a}` T`9V
§ -v verbosity How much troubleshooting info to print
gQQ"i(]"o5N0§ -w Print out results in HTML tables
7^!~VoD[8j+pM{0§ -i Use HEAD instead of GET51Testing软件测试网&Z,g(kS?"E
§ -x attributes String to insert as table attributes
cs:wf*I[vF-w0§ -y attributes String to insert as tr attributes51Testing软件测试网1b6Zn I%^
§ -z attributes String to insert as td or th attributes51Testing软件测试网0@ V;D+JS(GK@+C
§ -C attribute Add cookie, eg. 'Apache=1234' (repeatable)
r:b3m#J`\;VQr:n_J0§ -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: zop'
q#Ed5zY0R8H9U[#C0§ Inserted after all normal header lines. (repeatable)
D:WC,Qga0§ -A attribute Add Basic WWW Authentication, the attributes
:]UYs9z"I;G0§ are a colon separated username and password.51Testing软件测试网9D A:U&K,ZE
§ -P attribute Add Basic Proxy Authentication, the attributes
n6{C'eIB8R0§ are a colon separated username and password.
h)v#]"xS3A0§ -X proxy:port Proxyserver and port number to use51Testing软件测试网 F"R*R3A'\%V
§ -V Print version number and exit51Testing软件测试网,o4ER4\S!Oy'b H
§ -k Use HTTP KeepAlive feature
A`%K9V*WEY%@.y0§ -d Do not show percentiles served table.
']CWWE2XJ-g0§ -S Do not show confidence estimators and warnings.
gn*|T$rbtP0§ -g filename Output collected data to gnuplot format file.51Testing软件测试网%YHTwK B
§ -e filename Output CSV file with percentages served
~I ME_,Y$ulI0§ -s Use httpS instead of HTTP (SSL)
kB.T/ZmY&LV)Gs5i0§ -h Display usage information (this message)51Testing软件测试网-PI6a0W)aI
ab 使用51Testing软件测试网9DYO#Z^p9_&B
ab使用范例:
]Yi,F,x'N0要执行 1000 次的 connection, 20 次的 concurrent (并行, 同时):51Testing软件测试网 l3u$R hJD
语法: ab -n 1000 -c 20 http://localhost/
Hb'P_ p*w(T8o0B.w0产生出来的结果. 要注意的是以下几个:
XeR[\!C|k"LG&{#H0§ Time taken for tests: 总共执行花了多久的时间.(以上 1000 次共多久)
!{T1\5wB0§ Requests per second: 每秒平均可以处理多少个 connection.51Testing软件测试网&R0R;}!G3K3\
6s-Ujt_@a;pa9H0
$X6H%Q,{*_8gE(pN0
具体有兴趣,大家可以研究下
0l-C$b2@B:l0ab 可运行在linux & windows平台~51Testing软件测试网C7K K7D| O9E&i
nlz?6^Y`?0