遇到tomcat closedwait相关解决方案
方案一,在tomcat的workers.properties里面配置相关条件
worker.tomcat.lbfactor=50
worker.tomcat.cachesize=10
worker.tomcat.cache_timeout=600
worker.tomcat.socket_keepalive=1
worker.tomcat.socket_timeout=300
方案二,优化服务器内核参数(/etc/sysctl.conf)
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_keepalive_time=1800
net.ipv4.tcp_keepalive_probes=4
net.ipv4.tcp_keepalive_intvl=15
方案三,关闭tomcat的keepalive参数
方案四,做定时任务检查httpd进程数目,一旦发现httpd进程数目异常,就重启apache和tomcat
<strong> 针对于本项目目前的状况,我采用了方案四,编写了linux shell脚本如下:</strong>
#!/bin/sh
httpcount=`ps -ef|grep httpd|wc -l`
echo $httpcount
if [ $httpcount -gt 900 ]; then
killall httpd
killall java
/cicro/wcm/bin/startas.sh
echo "Restart successfully because of much useless process."
else
echo "It is OK!"
fi
本文只是记录网上相关解决方案,原链 http://www.myexception.cn/operating-system/1276416.html