Hystrix配置

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

  1. 是否在3次故障或之后打开电路
  2. 3次并发故障后打开电路.

通过文档链接

有人可以回答吗?

 

 

mou*_*ler 45

Hystrix断路器的工作原理: Hystrix不提供在一定次数的故障后断路的断路器.如果出现以下情况,Hystrix电路将断开:

在持续时间的一个时间内,metrics.rollingStats.timeInMilliseconds导致处理异常的动作的百分比超过errorThresholdPercentage,条件是在时间跨度内通过电路的动作的数量至少是requestVolumeThreshold


什么是requestVolumeThreshold? requestVolumeThreshold是电路计算百分比故障率之前,必须满足(在滚动窗口内)通过电路的呼叫(数量)的最小阈值.仅当满足此最小音量(在每个时间窗口中)时,电路才会将您的呼叫的故障比例与您errorThresholdPercentage配置的故障比例进行比较.

想象一下,没有这样的最小音量通过电路阈值.想象一下在时间窗口错误中的第一个调用.您将有1个呼叫中的1个是错误,= 100%失败率,这高于您设置的50%阈值.所以电路会立即断开.

requestVolumeThreshold存在让这种情况不会发生.有效地说,在每个时间窗口至少接收到呼叫之前,通过电路的错误率在统计上并不显着(并且不会被比较errorThresholdPercentage)requestVolumeThreshold.

  • 有关断路器如何工作的更多详细信息,请参见https://github.com/Netflix/Hystrix/wiki/How-it-Works#circuit-breaker。您配置的3个故障并不多。Hystrix断路器根据_percentage_错误(您已配置的`errorThresholdPercentage = 50`%)而中断,这些错误是在给定时间窗口内的所有呼叫中考虑的。“ requestVolumeThreshold = 3”(按我的原始答案)是最小通话音量阈值,必须在同一时间窗口内满足此条件,以使%age计算具有统计意义。 (2认同)