天天看点

使用Siege测试Web服务器

  参见 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,再安装。

#!/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);

$(make_link delete);

  测试命令

  siege -c20 -r2 -f link.out

  参数说明:

  -c20 并发20个用户

  -r2 重复循环2次

  -f link.out 任务列表:url列表

  测试结果:

** siege 3.0.0

** preparing 20 concurrent users for battle.

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

  这样测试,效果也良好,就是费时间。

最新内容请见作者的github页:http://qaseven.github.io/