問題描述:
發現,在訪問任何一個接口后,接着的接口在短時間內訪問速度都很正常。
始終是隔一段時間后的第一個接口訪問速度很慢。
同樣的jre、springboot在他的centos虛擬機上並未出現該問題,所以推測有可能是linux版本差異,或是安全策略配置問題,亦或是linux存在這么一個可以配置默認隨機數獲取算法的方式,有待深究。
參考:
https://my.oschina.net/malq/blog/1614127
https://www.cnblogs.com/mightyvincent/p/7685310.html
https://segmentfault.com/q/1010000010792585
https://www.2cto.com/kf/201806/751742.html
https://blog.csdn.net/wwd0501/article/details/79558447
解決方案:
1.
找到安裝的jre目錄,如jre/lib/security,然后修改java.security文件的如下:
securerandom.source=file:/dev./urandom
別人的服務器,不能亂調,還沒試
2.
在啟動時指定參數的方式,如下:
-Djava.security.egd=file:/dev/./urandom
但我設置了沒用,具體原因不明。
3.
spring-boot-starter-parent從1.4.2版本升級到1.5.9版本
親測有效,從1.5.10降到1.5.9
4.
打成 war 包部署到正常的 tomcat 上
暫時不嘗試
5.
將內置Tomcat的改為undertow,未嘗試
修改pom文件
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency>