【问题标题】:Use of execution.timeout.enabled along with execution.isolation.thread.timeoutInMilliseconds in Hystrix在 Hystrix 中使用 execution.timeout.enabled 和 execution.isolation.thread.timeoutInMilliseconds
【发布时间】:2020-01-25 10:13:40
【问题描述】:

在我们的项目中,我们使用下面的 Hystrix 配置。我对 command.default.execution.timeout.enabled 属性 感到困惑。它被设置为 false,但我们还有另一个属性指定 timeoutInMilliseconds,根据我的理解,它指定了调用者将观察到超时的时间。因此,如果执行超时首先设置为 false,那么拥有第二个属性有什么意义呢?如果我的理解不正确,请告诉我

#
# Hystrix configuration
#

hystrix:
  command.default.execution.timeout.enabled: false
  command.default.execution.isolation.thread.timeoutInMilliseconds: 60000

【问题讨论】:

    标签: microservices hystrix circuit-breaker


    【解决方案1】:

    首先,请浏览文档here。详细说明。在页面的开头,有“默认”的定义。请检查一下。

    现在来回答您的具体问题
    默认情况下,command.default.execution.timeout.enabled 值设置为 true。正如您在此section 中看到的那样。所以用这样的代码

    command.default.execution.timeout.enabled: false
    

    您将其覆盖为假。这意味着任何调用都不会被 hystrix 超时。但是您也可以在同一部分中看到,我们可以使用命令键为特定实例启用或禁用。

    同样的事情也适用于command.default.execution.isolation.thread.timeoutInMilliseconds

    我们有一个默认值,我们也可以为特定的命令键更改这个值。

    假设你现在有这个

    hystrix:
      command.default.execution.timeout.enabled: false
      command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
    

    几天后你可以添加类似的东西

    command.myinstancekey.execution.timeout.enabled: true
    

    在这种情况下,只为 myinstancekey 启用超时,它会在 60000 时超时,因为它从

    获取值
    command.default.execution.isolation.thread.timeoutInMillisecond
    

    如果你有类似的东西

    command.myinstancekey.execution.isolation.thread.timeoutInMillisecond: 30000 
    

    然后将 30000 作为 mysinstancekey 的超时值

    【讨论】:

      猜你喜欢
      • 2018-08-03
      • 1970-01-01
      • 2017-03-25
      • 2014-12-18
      • 2018-07-15
      • 2018-12-27
      • 2015-10-01
      • 2018-04-15
      • 2016-02-06
      相关资源
      最近更新 更多