[大并发]自虐Apache,ab压力测试

内存
ps aux |grep myapache |grep -v grep |awk 'BEGIN{sum=0}{sum+=$4}END{print sum}'
cpu
ps aux |grep myapache |grep -v grep |awk 'BEGIN{sum=0}{sum+=$3}END{print sum}'

参数

-n 请求数 
-c 并发数
-t xx秒 (上述请求,多少时间内执行完)
-w 以HTML表的格式输出结果
-p 包含了需要POST的数据的文件

执行命令

./ab -n 100 -c 100 -t 60 -w http://172.16.180.140:8081/ > /usr/local/myapache/htdocs/test.html

执行压力测试后,把文件放到网站目录里。
这样我们
就可以在外部查看内容

执行过程中 我们同时写个脚本 ckapache

1、同时检测 apache进程数
2、查看内存占用

我们开始调整prefork参数

 StartServers             50     #apache启动时的默认进程数
    MinSpareServers          50     #最小空闲进程
    MaxSpareServers         100     #最大空闲进程
    ServerLimit             1000  
    MaxRequestWorkers       1000  #最大请求量 默认256 如果要更改就要加上面的ServerLimit
    MaxConnectionsPerChild   500  #每个进程处理的连接数

修改好后,一定要先stop 。再start .restart没用

Ab命令的一些解释 http://www.365mini.com/page/apache-benchmark.htm Ab其他程序员做的测试
http://www.jianshu.com/p/43d04d8baaf7

发布了65 篇原创文章 · 获赞 3 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/web_orange/article/details/78795040