压测工具总结

来源:互联网 发布:dota2数据查询网站 编辑:程序博客网 时间:2024/04/29 20:24

1.server

server log

服务器端查看性能

tail -f  nginx.log | awk '{print $4;}' | sort | uniq -c

server network

有很多时候,你不清楚浏览器到底是怎么请求的消息

apache服务器为例子,首先停止服务器

/etc/init.d/httpd start|stop|restart|reload|status

使用万能工具nc

nc -l 80

截获浏览器请求,安装原样,使用压测工具请求即可~


2.jmeter

没有研究过,不过cookie需要单独写入


3.ab

ab -c 2000 -n 50000 http://xxxxxx

how to deal with post
<span style="font-size:10px;"><span style="font-size:10px;"><span style="font-size:10px;"><?php$file=fopen('log.txt','a+');fwrite($file,date("Y-m-d H:i:s"));fwrite($file," ");fwrite($file,$_REQUEST['test']);fwrite($file,"\r\n");fclose($file);?></span></span></span>
压测上面的php页面
ab -c 1 -n 10 -p ff.txt -T 'application/x-www-form-urlencoded' http://10.129.192.84/test.php
1.content-type必须设置为 'application/x-www-form-urlencoded'
2.ff.txt是post的内容 test=abc 
如果有多条记录,内容可以写成
test1=a&test2=b
下面这种格式是错误的,ab会把整个a回车test2=b 当作test1这个field传送出去 
test1=a
test2=b

how to deal with cookie
非常简单,没有网上说的那么复杂,你只需要 -C ‘ssuv=asdf; ppinfo=ascgasd; ... ’ 将你的cookie放到单引号中就行了,cookie里面的格式原封不动

parameter
http://100continue.iteye.com/blog/1325398

4.pylot

具体使用看我以前的文章

使用pylot压测时,有时候返回一种错误 504 : Gateway Timeout with urllib2

5xx status codes are problems with the server (compared with 4xx status codes, which are problems with the client). This means you sent the server a valid request, but the server was unable to serve a valid response.

Your code is fine, but the server (or in this case, a gateway that the server is using) is having problems. You just need to wait patiently for the server to resolve its own issues, or contact the server administrator and inform them that their server is misbehaving.


5.conclusion

几种工具比较起来

ab性能比较好,可以并发压力比较大,但是服务比较笨,无法处理302跳转这些动作

pylot性能稍差,但是文档和报告都比较好,最好的是可以改动源码,对问题进一步跟踪


http://www.vpser.net/opt/webserver-test.html


0 0
原创粉丝点击