Spring cloud Netflix中的超时配置


一般SpringCloud中超时配置,含Hystrix/Ribbon两部分:

ribbon:
  ReadTimeout: 120000
  ConnectTimeout: 120000
  
hystrix:
  command:
    default:
      execution:
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 120000

hystrix thread timeout需要比ribbon timeout设置时间长。
ribbon有retry机制,如果timeout设置时间短,则无法retry。

在zuul中,如果使用的是服务发现,ribbon timeout同上。
如果使用的指定URL形式,ribbon timeout需要如下配置:

zuul:
  host:
    connect-timeout-millis: 120000
    socket-timeout-millis: 120000

Zuul官方说明

8.13 Zuul Timeouts
If you want to configure the socket timeouts and read timeouts for requests proxied through Zuul, you have two options, based on your configuration:
If Zuul uses service discovery, you need to configure these timeouts with the ribbon.ReadTimeout and ribbon.SocketTimeout Ribbon properties.
If you have configured Zuul routes by specifying URLs, you need to use zuul.host.connect-timeout-millis and zuul.host.socket-timeout-millis.


文章作者: Ellen Dan
版权声明: 本博客所有文章除特別声明外,均采用 CC BY-SA 4.0 许可协议。转载请注明来源 Ellen Dan !
评论
  目录