推荐:Apache 压力测试工具ab
上一篇 / 下一篇 2016-03-29 19:06:25 / 个人分类:测试工具
51Testing软件测试网 HnnD,X2BHy
!INP0AQ0^{ r0关于压力测试,很多同学只知道LR、jmeter
/`4[V$y&tr0在 Apache 有个叫 ab(ApacheBench) 的程序, 此程序是专门用在做压力测试用的软件. ApacheBench(ab) 用来测试 apache 执行效率,可以用来测试网站的压力工具.
8cGZ!?/S)M0ab 参数
[ h)tf1Uh+Cd0ab 参数:
8V/@ Wr.U{(V0Usage: /usr/sbin/ab [options] [http[s]://]hostname[:port]/path
BGy;iq,Y0Options are:51Testing软件测试网9F*MhFmc k
§ -n requests Number of requests to perform
G O'a1ju0§ -c concurrency Number of multiple requests to make51Testing软件测试网]#z&W{,] E
§ -t timelimit Seconds to max. wait for responses51Testing软件测试网9M [XdP;N3`6Dv'a
§ -p postfile File containg data to POST51Testing软件测试网b:^.K/{ vW"{
§ -T content-type Content-type header for POSTing
R7~!^?8``(n0§ -v verbosity How much troubleshooting info to print
m?+P:o|'Lq$J/d0§ -w Print out results in HTML tables51Testing软件测试网j*R$V4Ds2o[(?9W/y.Oi+x
§ -i Use HEAD instead of GET51Testing软件测试网'vW~S#Gya
§ -x attributes String to insert as table attributes
r-dy4L(gV0§ -y attributes String to insert as tr attributes51Testing软件测试网t-Sz![p"VkT!F Hu
§ -z attributes String to insert as td or th attributes51Testing软件测试网7rT/]kq^5w4G:[-|\b
§ -C attribute Add cookie, eg. 'Apache=1234' (repeatable)51Testing软件测试网;|A;iyV$X
§ -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: zop'51Testing软件测试网DZ6TuJb
§ Inserted after all normal header lines. (repeatable)
Wg)K KRx4q#zm0§ -A attribute Add Basic WWW Authentication, the attributes
9Aams#{H0§ are a colon separated username and password.51Testing软件测试网z,ai'C]#^z(s
§ -P attribute Add Basic Proxy Authentication, the attributes51Testing软件测试网5e3l2S6? o
§ are a colon separated username and password.
i4??P2~2m0§ -X proxy:port Proxyserver and port number to use51Testing软件测试网2e;@l `%j3d
§ -V Print version number and exit51Testing软件测试网q[E L0DR%^
§ -k Use HTTP KeepAlive feature51Testing软件测试网6C5c&Vy)K
§ -d Do not show percentiles served table.
3iP^KT:u0§ -S Do not show confidence estimators and warnings.
Z[wMJ h)_0§ -g filename Output collected data to gnuplot format file.
"o1j"\8exi2q0§ -e filename Output CSV file with percentages served51Testing软件测试网-L3x#PGiu3h\]
§ -s Use httpS instead of HTTP (SSL)
$JX%\%e)T5{Kr2J0§ -h Display usage information (this message)51Testing软件测试网8u+o`I,j,q7I
ab 使用
JB?OJh2_0ab使用范例:
+T2X!|8B?.wl-B Vm0要执行 1000 次的 connection, 20 次的 concurrent (并行, 同时):
/]:J5F(s0c BjA0语法: ab -n 1000 -c 20 http://localhost/51Testing软件测试网a e8|;J)Q3b5C}1tP
产生出来的结果. 要注意的是以下几个:51Testing软件测试网&Pi*I)M P4I$@V S|&Aw
§ Time taken for tests: 总共执行花了多久的时间.(以上 1000 次共多久)51Testing软件测试网J)KO/Kt;z.} n
§ Requests per second: 每秒平均可以处理多少个 connection.