Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] mil


linux运行springboot项目,重启后第一次访问非常慢

日志打印

Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [21,543] milliseconds.

有两种解决办法:

1)在Tomcat环境中解决

可以通过配置JRE使用非阻塞的Entropy Source。

在catalina.sh中加入这么一行:-Djava.security.egd=file:/dev/./urandom 即可。

加入后再启动Tomcat,整个启动耗时下降到Server startup in 2912 ms。

2)在JVM环境中解决

打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:

securerandom.source=file:/dev/urandom 

替换成

securerandom.source=file:/dev/./urandom


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM