Tomcat网页加载过慢的排查---调整time_wait连接过多
1、Tomcat运行内存
JAVA_OPTS="-server -Xms1024m -Xmx6144m -Xss1024K"
2、server.xml 配置
vim server.xml
<Connector port="16000" protocol="HTTP/1.1"
connectionTimeout="40000"
redirectPort="8443" URIEncoding="UTF-8"
acceptCount="4000" maxThreads="5000"
compression="on" compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
disableUploadTimeout="true" debug="0"
maxHttpHeaderSize="8192" useBodyEncodingForURI="true" minProcessors="100" maxProcessors="5000"
minSpareThreads="1000" maxSpareThreads="4000" enableLookups="false"/>
这样设置启用压缩,设置最大连接数。
3、java随机数函数设置
jdk目录下:jdk1.8.0_131/jre/lib/security
vim java.security
找到securerandom.source=file:/dev/random将其替换为:securerandom.source=file:/dev/./urandom
4、tcp 连接的time_wait参数
vi /etc/sysctl.conf
net.ipv4.tcp_max_tw_buckets=3200
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
# sysctl -p
# netstat -lanput| grep 18082 |grep TIME_WAIT|wc -l && netstat -lanput|grep 18081 |grep TIME_WAIT|wc -l
将 tcp 连接time_wait的数量控制在3200