The Spring Cloud Zuul module itself contains dependencies on hystrix and ribbon. When we use zuul to configure routes through a combination of path and serviceId, we can adjust various time-out mechanisms of routing requests through the configuration of hystrix and ribbon.
1 ribbon configuration example
Configure the connection timeout time of 1 second, the request processing time of 2 seconds, the unified service server tries to reconnect once, switch server to reconnect once
ribbon: ConnectTimeout: 1000 ReadTimeout: 2000 MaxAutoRetries: 1 MaxAutoRetriesNextServer: 1
2 Examples of hystirx configuration
hystrix: command: default: execution: isolation: thread: timeoutInMilliseconds: 60000
It should be noted here that the configuration time of hystrix should be greater than the sum of all retry times of ribbon. I configured 2 retrys above, including the first request, and the three times are 6 seconds.
Quoting an explanation from the official master
When using Hystrix commands that wrap Ribbon clients you want to make sure your Hystrix timeout is configured to be longer than the configured Ribbon timeout, including any potential
retries that might be made. For example, if your Ribbon connection timeout is one second and
the Ribbon client might retry the request three times, than your Hystrix timeout should
be slightly more than three seconds.
3 Open zuul's retry configuration:
zuul: retryable: true
Pay special attention to the retry configuration of zuul, which requires retry to spring, otherwise it will be useless to configure it.
<dependency> <groupId>org.springframework.retry</groupId> <artifactId>spring-retry</artifactId></dependency>
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.