解决办法
1、Spring Cloud Gateway 增加 JVM启动参数
后进先出策略,确保获取的连接最大概率是最近刚被用过的
-Dreactor.netty.pool.leasingStrategy=lifo
2、后端服务配置
后端服务连接超时时长改为10秒(默认20s),超时没有数据交互则关闭连接。
server:
tomcat:
connection-timeout: 10000
3、Spring Cloud Gateway 增加配置
设置连接的最大空闲时长为5秒(默认NULL:响应完成即可关闭),超时则关闭连接释放资源。这个时长的设置要小于后端服务的连接超时时长,确保网关回收请求在后端服务回收请求之前完成。
spring:
cloud:
gateway:
httpclient:
pool:
max-idle-time: 5000
评论