web-benchmark
环境
1 | ulimit -a |
webbench
webbench是一枚强大得可以的压力测试工具,它最多可以模拟3万个并发连接去测试网站的负载能力
webbench -c 并发数 -t 运行测试时间 URL
webbench -c 5000 -t 120 http://xxxx
ab
ab是Apache自带的压力测试工具,非常小巧,可惜的是在mac下面表现不佳,跳动太大,而且还会出现 apr_socket_recv: Connection reset by peer (54)
ab -c 并发数 -n 请求数 URL
ab -c 1000 -n 10000 http://xxx
siege
siege -c 并发数 -t 运行测试时间 URL
siege -c 1000 -t 5s URL
这里要注意的是-t后面的时间要带单位,s表示秒,如果不带,就是分钟,分钟的单位,还是挺长的,所以要注意一下。
Tsung
ubuntu下安装:
sudo apt-get install erlang erlang-src //不是必须要装
sudo apt-get install perl5
sudo apt-get install libtemplate-perl //必须安装模板,否则无法生成report.html,报Can’t locate Template.pm
sudo apt-get install gnuplot-x11 //gnuplot有好几种,都差不多,我这边装的是gnuplot-x11.
http://tsung.erlang-projects.org/ 下载–>解压–>./configure–>make–>sudo make install
sudo apt-get install tsung,不过我直接下的官网的,没试过用apt-get安装
安装完,tsung放在/usr/bin/tsung,可以直接用 , 下面讲如何生成report.html
mkdir ~/.tsung
cp /usr/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml //中挑一两个例子拷贝到 ~/.tsung/tsung.xml 作为配置文件
配置 tsung.xml //不详细讲了,见备注给出的两篇博文.
tsung start //开启测试,会在~/.tsung 下生成log文件
cd ~/.tsung/log/20131108-16** //进入对应的log中
sudo /usr/lib/tsung/bin/tsung_stats.pl //自动分析生成 report.html
拷贝report.html到 正常目录下,用浏览器打开,即可看到对应数据.
参考文献
http://www.blogjava.net/duanzhimin528/archive/2010/09/01/330582.html //tsung的
http://tiandiou.blog.163.com/blog/static/2355668220115392725727/ //tsung的
http://blog.csdn.net/wudongxu/article/details/6326381 //tsung的
http://cqfish.blog.51cto.com/622299/138726 (比较详细) //ab的
http://www.vpser.net/opt/webserver-test.html // 综合比较几个压力测试工具的
http://hi.baidu.com/software_one/item/26a50ef1a67c2511ce9f32e0
http://www.cnblogs.com/zhongyuan/p/3038141.html