使用Siege测试Web服务器

发表于:2014-9-11 13:40

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:tangxiaosheng    来源:51Testing软件测试网采编

  好处是可以对一组url进行测试
  参见 http://www.blogjava.net/crespochen/archive/2009/06/02/279573.html 和 http://baike.baidu.com/link?url=Uv0KtwM83hvFTjudQsP37FIfeUDJxMW4Kvodfk6oSTJ4B4ctpr1R6P4CGXdyMExyU7rGL2bold_aGJHwKaV2l_
  郭扬提供了1.73上的应用,拷贝到/guodian/uap2,部署上Weblogic的Server-0(端口号是7010)。uap2依赖于uap_server。通过http访问是
  查询
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/
  增加:
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/insert?uuid=XXX&name=XXX
  修改:
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/update?uuid=XXX&name=XXX
  删除
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/delete?uuid=XXX
  我们在1.74上做测试。
  yum -y install siege #安装siege,安装不上的话,就从前面提供的URL上下载siege,再安装。
  据此,写了个shell生成url
#!/bin/bashfunction get_random_name(){MATRIX="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"LENGTH=8while[${n:=1}-le$LENGTH]; doPASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"let n+=1doneecho$PASS}function make_link(){act=$1#echo $actfor i in$seqc; do#echo $i
linkarr[$i]="\$link/$act?uuid=${idarr[$i]}&name=$(get_random_name)"echo${linkarr[$i]}>>$outdone}num=$1out=$2[ x$num = x ]&&num=10[ x$out = x ]&&out=link.out
link=http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase
declare-a idarr
seqc=`seq$num`for i in$seqc; do
idarr[$i]=$[$RANDOM%1000]doneecholink=$link>$outecho${idarr[@]}declare-a linkarr
$(make_link insert);
echo \$link/>>$outecho>>$out
$(make_link update);
echo \$link/>>$outecho>>$out
$(make_link delete);
echo \$link/>>$outecho>>$out
  测试命令
  siege -c20 -r2 -f link.out
  参数说明:
  -c20 并发20个用户
  -r2 重复循环2次
  -f link.out 任务列表:URL列表
  测试结果:
** SIEGE 3.0.0
** Preparing 20 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200   0.37 secs:     340 bytes ==> GET  /sguap-client/SmallCase/rest/smallCase/insert
HTTP/1.1 200   0.38 secs:     340 bytes ==> GET  /sguap-client/SmallCase/rest/smallCase/insert
...............................................  #代替很多条HTTP/1.1 ...
Transactions:          40 hits
Availability:      100.00 %
Elapsed time:        2.14 secs
Data transferred:        0.01 MB
Response time:        0.21 secs
Transaction rate:       18.69 trans/sec
Throughput:        0.01 MB/sec
Concurrency:        3.87
Successful transactions:          40
Failed transactions:           0
Longest transaction:        0.58
Shortest transaction:        0.00
  Concurrency是并发数
  siege还包含了一些辅助工具:bombardment,是一个辅助工具:用于按照增量用户压力测试。
  bombardment link.out 5 5 10 1
  这样测试,效果也良好,就是费时间。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号