无法设置功能区和hyxtrix的超时时间

时间:2018-08-21 17:04:08

标签: spring-boot hystrix netflix-ribbon

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

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

使用 Finchley.SR1 BTW。

总是出现相同的错误:

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]

2 个答案:

答案 0 :(得分:0)

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

ribbon:
  ConnectTimeout: 2000
  ReadTimeout: 2000

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

PS

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

答案 1 :(得分:0)

尽管它说未知属性,但是在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