tomcat7/8/9在linux环境下启动慢的优化办法

2019-02-08  本文已影响0人  司寒_2019

云服务器:阿里云CentOS7.3 64,Tomcat:9.0.14.0

tomcat webapps下的项目
tomcat启动耗时

现象:如上图所示,tomcat官网下载的压缩包,未做任何添加,启动耗时11分34秒

原因
Tomcat 7/8都使用org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom类产生安全随机类SecureRandom的实例作为会话ID,这里花去了342秒,也即接近6分钟。

解决办法

[root@sihan ~]# vim /usr/lib/jvm/jdk1.8.0_202/jre/lib/security/java.security 
# Specifying this System property will override the
# "securerandom.source" Security property.
#
# In addition, if "file:/dev/random" or "file:/dev/urandom" is
# specified, the "NativePRNG" implementation will be more preferred than
# SHA1PRNG in the Sun provider.
#
securerandom.source=file:/dev/./urandom

修改前启动耗时



修改后启动耗时


image.png

修改完后会有明显的改善效果

上一篇 下一篇

猜你喜欢

热点阅读