Zuul 在长请求中超时
Zuul timing out in long-ish requests
我正在使用前端 Spring 云应用程序(微服务)作为 Zuul 代理(@EnableZuulProxy
)将请求从外部源路由到使用 [= 编写的其他内部微服务21=]云(spring开机).
Zuul 服务器直接来自示例部分的应用程序
@SpringBootApplication
@Controller
@EnableZuulProxy
@EnableDiscoveryClient
public class ZuulServerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ZuulServerApplication.class).web(true).run(args);
}
}
我在本地 运行 这组服务,似乎一切正常,但如果我 运行 它在有一定负载的网络上,或通过 VPN,那么我开始看到 Zuul转发错误,我在日志中看到客户端超时。
有没有什么办法可以改变 Zuul 转发的超时时间,这样我就可以消除我眼前的这个问题?这有哪些可访问的参数设置?
要设置的属性为:一般为 ribbon.ReadTimeout
,特定服务为 <service>.ribbon.ReadTimeout
,以毫秒为单位。 Ribbon wiki has some examples. This javadoc 有 属性 个名字。
在我的例子中,我必须更改以下内容 属性:
zuul.host.socket-timeout-millis=30000
我遇到过同样的问题:在长请求中,尽管设置了 ribbon.ReadTimeout=10000
.
,Zuul 的 hystrix 命令仍然在大约一秒后超时
我通过完全禁用超时解决了这个问题:
hystrix:
command:
default:
execution:
timeout:
enabled: false
另一种可行的方法是将 Zuul 的 Hystrix 隔离策略更改为线程:
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 10000
我不得不改变两个超时来强制 zuul 停止超时长-运行 请求。即使 hystrix 超时被禁用,ribbon 仍然会超时。
hystrix:
command:
default:
execution:
timeout:
enabled: false
ribbon:
ReadTimeout: 100000
ConnectTimeout: 100000
这对我有用,我必须在 application.yml
:
中设置连接和套接字超时
zuul:
host:
connect-timeout-millis: 60000 # starting the connection
socket-timeout-millis: 60000 # monitor the continuous incoming data flow
如果 Zuul 使用服务发现,您需要使用 ribbon.ReadTimeout
和 ribbon.SocketTimeout
功能区属性配置这些超时。
如果你通过指定URL配置了Zuul路由,你需要使用zuul.host.connect-timeout-millis
和zuul.host.socket-timeout-millis
按路线我的意思是
zuul:
routes:
dummy-service:
path: /dummy/**
只有 application.yml
上的这些设置对我有用:
ribbon:
ReadTimeout: 90000
ConnectTimeout: 90000
eureka:
enabled: true
zuul:
host:
max-total-connections: 1000
max-per-route-connections: 100
semaphore:
max-semaphores: 500
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 1000000
希望对大家有所帮助!
我有一个类似的问题,我正在尝试全局设置 timeout,以及 Hystrix 和 [= 的设置超时顺序32=]功能区很重要。
在花了很多时间之后,我最终得到了这个解决方案。由于数据量巨大,我的服务最多需要 50 秒。
更改超时的默认值之前要考虑的要点:
Hystrix 时间应大于 Ribbon ReadTimeout 和 ConnectionTimeout 的总时间。
仅对特定服务使用,这意味着不要全局设置(这不起作用)。
我的意思是使用这个:
command:
your-service-name:
而不是这个:
command:
default:
工作解决方案:
hystrix:
command:
your-service-name:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 95000
your-service-name:
ribbon:
ConnectTimeout: 30000
ReadTimeout: 60000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100
我正在使用前端 Spring 云应用程序(微服务)作为 Zuul 代理(@EnableZuulProxy
)将请求从外部源路由到使用 [= 编写的其他内部微服务21=]云(spring开机).
Zuul 服务器直接来自示例部分的应用程序
@SpringBootApplication
@Controller
@EnableZuulProxy
@EnableDiscoveryClient
public class ZuulServerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ZuulServerApplication.class).web(true).run(args);
}
}
我在本地 运行 这组服务,似乎一切正常,但如果我 运行 它在有一定负载的网络上,或通过 VPN,那么我开始看到 Zuul转发错误,我在日志中看到客户端超时。
有没有什么办法可以改变 Zuul 转发的超时时间,这样我就可以消除我眼前的这个问题?这有哪些可访问的参数设置?
要设置的属性为:一般为 ribbon.ReadTimeout
,特定服务为 <service>.ribbon.ReadTimeout
,以毫秒为单位。 Ribbon wiki has some examples. This javadoc 有 属性 个名字。
在我的例子中,我必须更改以下内容 属性:
zuul.host.socket-timeout-millis=30000
我遇到过同样的问题:在长请求中,尽管设置了 ribbon.ReadTimeout=10000
.
我通过完全禁用超时解决了这个问题:
hystrix:
command:
default:
execution:
timeout:
enabled: false
另一种可行的方法是将 Zuul 的 Hystrix 隔离策略更改为线程:
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 10000
我不得不改变两个超时来强制 zuul 停止超时长-运行 请求。即使 hystrix 超时被禁用,ribbon 仍然会超时。
hystrix:
command:
default:
execution:
timeout:
enabled: false
ribbon:
ReadTimeout: 100000
ConnectTimeout: 100000
这对我有用,我必须在 application.yml
:
zuul:
host:
connect-timeout-millis: 60000 # starting the connection
socket-timeout-millis: 60000 # monitor the continuous incoming data flow
如果 Zuul 使用服务发现,您需要使用 ribbon.ReadTimeout
和 ribbon.SocketTimeout
功能区属性配置这些超时。
如果你通过指定URL配置了Zuul路由,你需要使用zuul.host.connect-timeout-millis
和zuul.host.socket-timeout-millis
按路线我的意思是
zuul:
routes:
dummy-service:
path: /dummy/**
只有 application.yml
上的这些设置对我有用:
ribbon:
ReadTimeout: 90000
ConnectTimeout: 90000
eureka:
enabled: true
zuul:
host:
max-total-connections: 1000
max-per-route-connections: 100
semaphore:
max-semaphores: 500
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 1000000
希望对大家有所帮助!
我有一个类似的问题,我正在尝试全局设置 timeout,以及 Hystrix 和 [= 的设置超时顺序32=]功能区很重要。
在花了很多时间之后,我最终得到了这个解决方案。由于数据量巨大,我的服务最多需要 50 秒。
更改超时的默认值之前要考虑的要点:
Hystrix 时间应大于 Ribbon ReadTimeout 和 ConnectionTimeout 的总时间。
仅对特定服务使用,这意味着不要全局设置(这不起作用)。
我的意思是使用这个:
command:
your-service-name:
而不是这个:
command:
default:
工作解决方案:
hystrix:
command:
your-service-name:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 95000
your-service-name:
ribbon:
ConnectTimeout: 30000
ReadTimeout: 60000
MaxTotalHttpConnections: 500
MaxConnectionsPerHost: 100