问题描述
我正在尝试了解 Hystrix.我了解当服务调用 3rd 方服务并且该服务没有响应并且阈值已超过配置时,电路将打开并且继续调用将被短路.
I am trying to understand Hystrix. I understand when a service makes call to a 3rd party service and that service is not responding and threshold has been exceeded than the configuration, circuit will be opened and onward calls will be short circuited.
但我无法理解电路是如何再次闭合的.让我们假设我们的服务正在调用 3rd 方服务,并且该服务无法正常工作,因此电路已打开.5 分钟后,该服务开始正常工作,现在电路应该关闭.调用服务怎么知道第三方服务已经开始正常运行,现在应该关闭?
But I am not able to understand how circuit is closed again. Let us suppose our service is making call to 3rd party service and that service not not working fine so circuit is opened. After 5 minute that service has started working fine now circuit should be closed. How calling service knows this that the 3rd party service has started behaving fine, now circuited should be closed?
推荐答案
实际上有三种状态:OPEN、CLOSED 和 HALF_OPEN.一旦断路器打开并且经过了一定的时间,它就会让单个请求潜入.这是 HALF_OPEN 状态.如果成功,断路器闭合,否则它返回到 OPEN 状态,直到再次过去该时间量,在那里它再次进入 HALF_OPEN 状态.您可以使用 circuitBreaker.sleepWindowInMilliseconds 属性指定从 OPEN 到 HALF_OPEN 的转换之间的时间量.
There are actually three states: OPEN, CLOSED, and HALF_OPEN. Once the circuit breaker is OPEN and a certain amount of time has passed it lets a single request sneak through. This is the HALF_OPEN state. If successful the circuit breaker is closed, otherwise it returns to the OPEN state until that amount of time has passed again, where it enters the HALF_OPEN state once again. You can specify the amount of time between the transition to OPEN to HALF_OPEN using the circuitBreaker.sleepWindowInMilliseconds property.
这篇关于怎么电路又闭合了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!