在docker/centos系统里启动官方的tomcat时,发现启动过程很慢,需要几十秒,即使只用官方默认自带的几个应用启动也一样。
一查日志,发现是session引起的随机数问题导致的:
INFO: Deploying web application directory /data/server/install/apache-tomcat-7.0.55/webapps/ROOT
Aug 29, 2014 1:14:02 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation
using [SHA1PRNG] took [27,537] milliseconds.
这个问题之前在之前的这篇JVM上的随机数与熵池策略 已经分析过了,我们在ali-tomcat里为避免随机数引起的阻塞,设置过使用非阻塞熵池策略:
if [[ "$JAVA_OPTS" != *-Djava.security.egd=* ]]; then
JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"
fi
修改过后,立刻从之前的27秒降到了0.5秒:
INFO: Deploying web application directory /data/server/install/apache-tomcat-7.0.55/webapps/ROOT
Aug 29, 2014 2:10:13 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /data/server/install/apache-tomcat-7.0.55/webapps/
ROOT has finished in 515 ms
(责任编辑:IT) |