zoukankan      html  css  js  c++  java
  • SpringBoot系列: SpringBoot 启动慢的问题

    SpringBoot 应用启动速度往往很快, 但在某些Linux 服务器上可能会很慢, 可能超过1分钟, 有时候甚至启动不起来.

    下面过程耗时太长:
    IdGeneratorBase: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [140,108] milliseconds.


    原因是SpringBoot在生成Session Id时候会使用 SecureRandom 这个jre工具类, 以生成足够安全的随机数. 最终会用到在Linux的 /dev/random 这个阻塞型数字生成器, 它的特点是使用鼠标和键盘以及磁盘信息来产生熵, 但对于Linux 服务器, 鼠标和键盘活动可能会很少, 就有可能阻塞整个SpringBoot启动.


    解决办法是, 替换 /dev/random 为 /dev/./urandom. 具体为:

    方法一: 适合外置tomcat:
    在tomcat 的 catalina.sh 中增加下面的 JAVA_OPTS:
    -Djava.security.egd=file:/dev/./urandom

    方法二: 适合外置或内置tomcat:
    修改 $JAVA_PATH/jre/lib/security/java.security 文件,
    将 securerandom.source=file:/dev/random 替换为下面一行:
    securerandom.source=file:/dev/./urandom

  • 相关阅读:
    学指令 emacs篇
    c 排序 总结
    C# WinForm源码下载
    PetShop下载
    Visual Studio常用技巧
    人事信息管理系统(PMS)
    css实现细表格原理
    GridView导出Excel/Word
    dotnet程序员装机必备工具
    容器练习一
  • 原文地址:https://www.cnblogs.com/harrychinese/p/springboot_start_slow.html
Copyright © 2011-2022 走看看