Objective
In spring Cloud, the feign and ribbon may have failed the first call after consolidating the hystrix, how do you solve the problem?
The cause of the problem
Hystrix the default time-out is 1 seconds, and if the time is not yet responding, it will enter the fallback code. The first request tends to be slow (because of the lazy loading mechanism of spring, to instantiate some classes), the response time may be more than 1 seconds. After knowing the reason, let's summarize the solution to put you.
There are three solutions, taking feign as an example.
Method One
?
1 |
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000 |
The configuration is to change the Hystrix timeout to 5 seconds
Method Two
?
1 |
hystrix.command. default .execution.timeout.enabled: false |
This configuration, which disables the timeout period for Hystrix
Method Three
?
1 |
feign.hystrix.enabled: false |
This configuration is used to simply disable the feign hystrix. This practice is not recommended unless some special scenarios are used.
Summarize
The above is about the spring cloud to solve the Feign/ribbon first request failure of all content, hope that the content of this article on everyone's study or work can bring certain help, if there is doubt you can message exchange, thank you to the script home support.
Original link: http://www.itmuch.com/spring-cloud-feign-ribbon-first-request-fail/
Resolving the Feign/ribbon first request failure method in spring cloud