Jay*_*Jay 13 netflix short-circuiting circuit-breaker fail-fast hystrix
我正在尝试使用hystrix-javanica为我的应用程序实现hystrix.
我已经配置了hystrix-configuration.properties,如下所示
hystrix.command.default.execution.isolation.strategy=SEMAPHORE
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000
hystrix.command.default.fallback.enabled=true
hystrix.command.default.circuitBreaker.enabled=true
hystrix.command.default.circuitBreaker.requestVolumeThreshold=3
hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds=50000
hystrix.command.default.circuitBreaker.errorThresholdPercentage=50
Run Code Online (Sandbox Code Playgroud)
短路模式工作正常,但我对此有疑问 hystrix.command.default.circuitBreaker.requestVolumeThreshold=3
通过文档链接
有人可以回答吗?
mou*_*ler 45
Hystrix断路器的工作原理: Hystrix不提供在一定次数的故障后断路的断路器.如果出现以下情况,Hystrix电路将断开:
在持续时间的一个时间内,
metrics.rollingStats.timeInMilliseconds导致处理异常的动作的百分比超过errorThresholdPercentage,条件是在时间跨度内通过电路的动作的数量至少是requestVolumeThreshold
什么是requestVolumeThreshold?
requestVolumeThreshold是电路计算百分比故障率之前,必须满足(在滚动窗口内)通过电路的呼叫量(数量)的最小阈值.仅当满足此最小音量(在每个时间窗口中)时,电路才会将您的呼叫的故障比例与您errorThresholdPercentage配置的故障比例进行比较.
想象一下,没有这样的最小音量通过电路阈值.想象一下在时间窗口错误中的第一个调用.您将有1个呼叫中的1个是错误,= 100%失败率,这高于您设置的50%阈值.所以电路会立即断开.
的requestVolumeThreshold存在让这种情况不会发生.有效地说,在每个时间窗口至少接收到呼叫之前,通过电路的错误率在统计上并不显着(并且不会被比较errorThresholdPercentage)requestVolumeThreshold.