来点压力——tsung
昨日四川发生7.8级大地震,灾情陆续传来,在此,先向死难的同胞们默哀。。。。
最近用上了 Tsung ,传说中“压垮了N台服务器”的 download midi ringtones nickelback ringtones cell phone ringtones virgin mobile usa ringtones download nokia ringtones samsung polyphonic ringtones ericsson polyphonic ringtones sony free real tone ringtones free nextel ringtones ringtones composer free ringtones and wallpaper for cell phone download free ringtones virgin mobile 1600 nokia ringtones cell cingular free phone ringtones christian download free ringtones free real ringtones sprint free nokia mp3 ringtones cingular free phone ringtones sony ericsson ringtones download free ringtones t mobile Erlang 压力测试工具啊。在这里记一下流水帐。
安装
获取tsung 的源码
或
svn co http://svn.process-one.net/tsung/trunk
确保依赖关系
tsung 依赖了这些东西 erlang(废话,从源码编译 erlang 写的程序,能不装么) gnuplot perl5(如果想看 report 中的图形,就要装这个),将其一一装上。
编译安装
make
sudo make install
安装完成之后的 tsung 运行脚本在 /usr/bin/tsung ,在系统 path 之中,可以直接运行。
设置
从 /usr/share/doc/tsung/examples 中挑一两个例子拷贝到 ~/.tsung/tsung.xml 作为配置文件。我只需要 http 测试,所以:
tsung 采用了巧妙的 proxy 方式来“录制”测试脚本。具体来说,就是建立一个本机的 http proxy 默认使用 8090 端口,在配好 firefox 使用 localhost 8090 作为代理之后(推荐 foxyproxy 插件),所有“流经”这个 proxy 的 http 动作都会被记录下来,测试时可以“回放”这些步骤来产生请求。
tsung stop_recorder
“录制”完了,会得到一个 ~/.tsung/tsung_recorderXXXXXXXXXX.xml 文件,这就是测试时回回放的脚本。
将这个脚本加到 tsung.xml 之中
就像这样
<!ENTITY mysession1 SYSTEM "/home/yourname/.tsung/tsung_recorderXXXXXXXXXX.xml">
]>
...
<sessions>
&mysession1;
</sessions>
对配置稍作调整
<monitor host="localhost" type="erlang"></monitor>
</monitoring>
<!-- 需要配置到 localhost 无须密码的 ssh 登录(ssh via rsa_key),开启了这个配置可以,获得目标机器的 cpu 和 ram 消耗情况 -->
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users interarrival="2" unit="second"></users>
</arrivalphase>
</load>
<!-- 第1阶段1分钟(你可以自己多搞几个阶段),其中每2秒新建一个用户,每个用户都会完整执行 session 的测试脚本,最高并发约为 30 个,个人认为这个“逐渐加压”的方法比 ab xxxx 的“突然加压”要慢一些,但更科学一点 -->
运行
准备好了,加压运行。
运行完,在 ~/.tsung/log 目录会生成一个以时间命名的目录,进入这个目录
/usr/lib/tsung/bin/tsung_stats.pl
生成 html 的压力测试报告
慢慢欣赏吧。
除了 http 以外 tsung 还可以压很多东西,比如:jabber, postgreSQL 还可以写插件来给任何你想要测试的东西加压,配置文件也很“丰富多彩”,更多的内容情看文档。
注,以上内容在 ubuntu 8 下整理,其他平台,请自行探索。
你好!
我最近也在用Tsung来测试jabber server
但不明白这个recorder 过程怎样录制?
>tsung recorder
Error in process on node
>tsung stop_reocrder ##显示如下错误
Error in process on node ‘killer@hostname’ with exit value: {badarg,[{erlang,list_to_existing_atom,["ejabberd@localhost"]},{dist_util,recv_challenge,1},{dist_util,handshake_we_started,1}]}
能帮忙分析下马?
谢谢!
got no clue,俺没试过用 tsung 对 jabber 作压力测试。
Tsung Manual:4.5.1 (1) said: There’s no record for jabber
后面也有提到:如果想手写jabber的record, 可以参考6.6.3
对于jabber,没有recorder,需要自己手动写.可以参照tsung/example/下面的例子.
LZ,关于tsung的并发,我不是很理解。测试http时,每个用户都会去执行session.有的用户刚开始执行,有的用户就已经结束了.怎样在这里做好平衡.谢谢!
@newman
Hi Newman, sorry my chinese: I had the same problem and I solved by properly setting up the machine’s hostname. Check the output of the command ‘hostname -s’. Good luck!
—————-
您好,对不起,我的中文纽曼:我有同样的问题,我通过正确的设置了机器的主机解决。检查命令的输出’hostname -s’的。祝您好运!
Hi jackyz,
tsung1.3.3版本中是否支持load的duration 功能?我看手册上写的是支持的,但是在实际操作中并未支持。目前的需求是:我想让tsung就产生5个用户,然后这5个用户duration 1 hour,tsung支持这样的功能吗?期待您的回复!谢谢~
duration 是支持的呀, 5个用户可以一直在loop做请求直到duration 结束。
@mryufeng
感谢余老师,此需求已得到满足。在session里加loop循环即可
ther are lots of free ringtone sites on the internet if you just keep on searching on google;;;
你好,想请问一下组合脚本场景如何实现,类似想运行分别以不同的虚拟用户运行2个脚本?
我按上面的方式,tsung rocorder失败了,想自己写一个XML放进tsung.xml里面,请问能给个正确的格式吗?
按上面的步骤将脚本加到 tsung.xml 之中,运行的时候报错了
3780- fatal: {error,{whitespace_was_expected}}
["Config Error, aborting ! ",{fatal,{{error,{whitespace_was_expected}},{file,"./xxxxxxxxxxxx.xml"},{line,1},{col,20}}}]
most of the best ringtone sites are pay sites, does anyone know of a good free ringtone site? :~*
@Electric Shower ·
谢谢,这个问题已解决,但是在设置集群的时候,server无法调用client,报timeout错误
‘`* I am really thankful to this topic because it really gives up to date information -`”
我测试都正常执行,但是生成报告出错,我perl和libtemplate-perl 都安装了啊!求解!