天天看點

使用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/