【问题标题】:Not able to set timeout for ribbon and hyxtrix无法为功能区和 hystrix 设置超时
【发布时间】:2019-01-27 22:20:05
【问题描述】:

我正在尝试在 application.yml 中设置属性以设置功能区和 hystrix 的超时,但我无法做到这一点。我总是遇到同样的问题: “未知属性 hystrix.command”“未知属性ribbon.ConnectTimeout”

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 11000
ribbon:
  ConnectTimeout: 10000
  ReadTimeout: 10000

使用 Finchley.SR1 顺便说一句。

总是遇到同样的错误:

2018-08-21 19:18:31.695  WARN 13534 --- [io-8765-exec-10] o.s.c.n.z.f.r.s.AbstractRibbonCommand    : The Hystrix timeout of 3000ms for the command flight-service is set lower than the combination of the Ribbon read and connect timeout, 4000ms.
2018-08-21 19:18:32.752  WARN 13534 --- [io-8765-exec-10] o.s.c.n.z.filters.post.SendErrorFilter   : Error during filtering

com.netflix.zuul.exception.ZuulException: 
    at org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter.findZuulException(SendErrorFilter.java:114) ~[spring-cloud-netflix-zuul-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter.run(SendErrorFilter.java:76) ~[spring-cloud-netflix-zuul-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:117) [zuul-core-1.3.1.jar:1.3.1]
    at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193) [zuul-core-1.3.1.jar:1.3.1]
    at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157) [zuul-core-1.3.1.jar:1.3.1]
    at com.netflix.zuul.FilterProcessor.error(FilterProcessor.java:105) [zuul-core-1.3.1.jar:1.3.1]
    at com.netflix.zuul.ZuulRunner.error(ZuulRunner.java:112) [zuul-core-1.3.1.jar:1.3.1]

【问题讨论】:

  • 请查看此链接 stackoverflow.com/a/44918316/9183844

标签: spring-boot hystrix netflix-ribbon


【解决方案1】:

我去 Finchley 后遇到了同样的错误。调整ribbon.ConnectTimeout和ribbon.ReadTimeout后,错误消失了。

ribbon:
  ConnectTimeout: 2000
  ReadTimeout: 2000

尝试运行负载测试(例如在 jMeter 中),看看负载下服务器的最大响应时间是多少,可能读取 10000 毫秒,连接 10000 毫秒是不够的。

附言

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds 必须大于ribbon.ConnectTimeout + ribbon.ReadTimeout。

【讨论】:

    【解决方案2】:

    虽然它说未知属性,但在 zuul 网关中添加属性可以正常工作以调整超时。下面是我可以让它工作的配置。

    hystrix.command.default.execution.timeout.enabled= true
    
    ribbon.ReadTimeout=5000
    ribbon.ConnectTimeout=5000
    
    #(ribbon.ReadTimeout + ribbon.connectTimeout) * (1+ribbon.maxAutoRetries(default 0) * (ribbon.MaxAutoRetriesNextServer (default 1) + 1)
    
    #timeoutInMilliseconds= (5000 + 5000) * (1+0)*(1+1) =20000
    
    hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=21000
    

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 1970-01-01
      • 2012-01-06
      • 2016-02-06
      • 1970-01-01
      • 2023-03-22
      • 2016-11-29
      • 1970-01-01
      • 2020-05-13
      相关资源
      最近更新 更多