spring boot 首次请求Controller慢

问题描述:

发现,在访问任何一个接口后,接着的接口在短时间内访问速度都很正常。
始终是隔一段时间后的第一个接口访问速度很慢。

同样的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版本
正在尝试
 
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>

  

猜你喜欢

转载自www.cnblogs.com/silyvin/p/9269523.html