[popexizhi:
ab无法参数化,找了一下siege可以
// 执行 $ siege -c 5 -r 10 -f urls-demo.txt
$ siege -c 5 -r 10 -f /Users/WangYoungTom/temp/urls-demo.txt
参数说明: -c 是并发量,并发数为5人 -r 是重复次数, 重复10次 -f 指定使用文件,urls-demo.txt就是一个文本文件,每行都是一个url,会从里面随机访问的
Siege从Siege-V2.06起支持POST和GET两种请求方式。 如果想模拟POST请求,可以在urls-demo.txt中安装一下格式填写URL:
# URL (POST):
http://wangtest.com/index.php POST UserId=XXX&StartIndex=0&OS=Android&Sign=cff6wyt505wyt4c
http://wangtest.com/articles.php POST UserId=XXX&StartIndex=0&OS=iOS&Sign=cff63w5905wyt4c
]
参考:
https://www.jianshu.com/p/19b921511775
http://xstarcd.github.io/wiki/shell/siege.html
- Web性能压力测试工具之Siege详解: http://www.ha97.com/4663.html
- 系统吞吐量(TPS)、用户并发量、性能测试概念和公式:http://www.ha97.com/5095.html
- Siege官网:http://www.joedog.org/
- 下载地址
- 压力测试工具siege的用法:http://buzheng.org/blog/usage-of-siege.html
Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。
Sproxy做为一个代理侦听9001端口,可用于搜集正常访问的GET/POST请求、生成siege适用的Urls.txt文件格式。
安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # siege tar zxvf siege-3.0.6. tar .gz cd siege-3.0.6/ . /configure make make install # sproxy yum -y install perl-devel openssl-devel tar zxvf sproxy-1.02. tar .gz cd sproxy-1.02/ . /configure make make install |
参数说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | siege --help SIEGE 3.0.6 Usage: siege [options] siege [options] URL siege -g URL Options: -V, --version VERSION, prints the version number. -h, --help HELP, prints this section. -C, --config CONFIGURATION, show the current config. #在屏幕上打印显示出当前的配置,配置是包括在他的配置文件$HOME/.siegerc中, #可以编辑里面的参数,这样每次siege 都会按照它运行. - v , --verbose VERBOSE, prints notification to screen . #运行时能看到详细的运行信息 -q, --quiet QUIET turns verbose off and suppresses output. -g, --get GET, pull down HTTP headers and display the transaction. Great for application debugging. -c, --concurrent=NUM CONCURRENT users , default is 10 #模拟有n个用户在同时访问,n不要设得太大,因为越大,siege 消耗本地机器的资源越多 -i, --internet INTERNET user simulation, hits URLs randomly. #随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性) -b, --benchmark BENCHMARK: no delays between requests. -t, -- time =NUMm TIMED testing where "m" is modifier S, M, or H ex: -- time =1H, one hour test . #持续运行siege ‘n’秒(如10S),分钟(10M),小时(10H) -r, --reps=NUM REPS, number of times to run the test . #重复运行测试n次,不能与 -t同时存在 -f, -- file =FILE FILE, select a specific URLS FILE. #指定用urls文件,默认为siege安装目录下的etc/urls.txt #urls.txt文件:是很多行待测试URL的列表以换行符断开,格式为: #[protocol://]host.domain.com[:port][path/to/file] -R, --rc=FILE RC, specify an siegerc file #指定用特定的siege配置文件来运行,默认的为$HOME/.siegerc -l, --log[=FILE] LOG to FILE. If FILE is not specified, the default is used: PREFIX /var/siege .log #运行结束,将统计数据保存到日志文件siege.log中,可在.siegerc中自定义日志文件 -m, --mark= "text" MARK, mark the log file with a string. -d, --delay=NUM Time DELAY, random delay before each requst between 1 and NUM. (NOT COUNTED IN STATS) #hit每个url之间的延迟,在0-n之间 -H, --header= "text" Add a header to request (can be many) -A, --user-agent= "text" Sets User-Agent in request -T, --content- type = "text" Sets Content-Type in request Copyright (C) 2014 by Jeffrey Fulmer, et al. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- url文件格式_GET
server=172.17.19.80:80 http://${server}/q?k1=v1&k2=v2
- url文件格式_POST
server=172.17.19.80:80 http://${server}/q POST k1=v1&k2=v2
结果说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ** SIEGE 2.72 ** Preparing 300 concurrent users for battle. The server is now under siege.. done . Transactions: 30000 hits #完成30000次处理 Availability: 100.00 % #成功率 Elapsed time : 68.59 secs #总共使用时间 Data transferred: 817.76 MB #共数据传输 817.76 MB Response time : 0.04 secs #响应时间,显示网络连接的速度 Transaction rate: 437.38 trans /sec #平均每秒完成 437.38 次处理 Throughput: 11.92 MB /sec #平均每秒传送数据 Concurrency: 17.53 #实际最高并发连接数 Successful transactions: 30000 #成功处理次数 Failed transactions: 0 #失败处理次数 Longest transaction: 3.12 #每次传输所花最长时间 Shortest transaction: 0.00 #每次传输所花最短时间 |
没有评论:
发表评论