The Hystrix timeout of 20000ms for the command uaa-service is set lower than the combination of the

3283 ワード

Zuulの構成は次のとおりです.
server:
  port: 8000

spring:

#   
#  redis:
#    host: 192.168.124.100
#    password:
#    port: 6379
#   
  redis:
    database: 0
    cluster:
      nodes:
        - 192.168.111.192:6380
        - 192.168.111.192:6381
        - 192.168.111.192:6382
        - 192.168.111.192:6383
        - 192.168.111.192:6384
        - 192.168.111.192:6385
    jedis:
      pool:
        max-idle: 8
        min-idle: 0
        max-active: 8
        max-wait: -1
    timeout: 10000

  zipkin:
    base-url: http://localhost:8004
  sleuth:
    sampler:
      percentage: 1.0

eureka:
  instance:
    prefer-ip-address: true
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: http://localhost:8001/eureka/

#  
zuul:
  ribbon:
    eager-load:
      enabled: true #zuul    
  host:
    max-total-connections: 200
    max-per-route-connections: 20
    #          zuul   
    #   ribbon.ReadTimeout    ,        service-id   ,  ribbon.ReadTimeout  ,    url   ,     
    connect-timeout-millis: 10000
    socket-timeout-millis: 10000
  routes:
    uaa-service:
      path: /uaa/**
      serviceId: uaa-service
    code-service:
      path: /code/**
      serviceId: code-service
    user-service:
      path: /user/**
      serviceId: user-service
    order-service:
      path: /order/**
      serviceId: order-service
  #  Authorization        
  sensitive-headers:

#  Ribbon     
ribbon:
  ReadTimeout: 10000
  ConnectTimeout: 10000
#  MaxAutoRetries: 1
#  MaxAutoRetriesNextServer: 1

hystrix:
  command:
    default:
      execution:
        isolation:
          strategy: SEMAPHORE
          #  hystrix     
          thread:
            timeoutInMilliseconds: 20000

#Admin Client,     actuator       
management:
  endpoints:
    web:
      exposure:
        exposure: '*'
  endpoint:
    health:
      show-details: ALWAYS

アクセス時にエラーが表示されます.
The Hystrix timeout of 20000ms for the command uaa-service is set lower than the combination of the Ribbon read and connect timeout, 40000ms.

分析:
Ribbonの合計タイムアウト時間の計算式は次のとおりです.
ribbonTimeout = (RibbonReadTimeout + RibbonConnectTimeout) * (MaxAutoRetries + 1) * (MaxAutoRetriesNextServer + 1)

ここで、MaxAutoRetriesのデフォルトは0、MaxAutoRetriesNextServerのデフォルトは1なので、ここでの具体的な値は(10000+10000)*(0+1)*(1+1)=40000です.
Hystrixのタイムアウト時間は20000<40000で、論理的に言えばhystrixTimeoutはribbonTimeoutより大きくなければならない.そうしないとhystrixが溶断した後、ribbonの再試行は意味がない.
したがって、この問題は簡単です.hystrixを構成するタイムアウト時間は40000以上です.以下のようにします.
ribbon:
  ReadTimeout: 10000
  ConnectTimeout: 10000
#  MaxAutoRetries: 1
#  MaxAutoRetriesNextServer: 1

hystrix:
  command:
    default:
      execution:
        isolation:
          strategy: SEMAPHORE
          #  hystrix     ,   (RibbonReadTimeout + RibbonConnectTimeout) * (MaxAutoRetries + 1) * (MaxAutoRetriesNextServer + 1)
          thread:
            timeoutInMilliseconds: 40000

ribbonのtimeOutを下げたり、再試行回数を下げたりします.
参照先:
https://www.cnblogs.com/jizhong/p/11551797.html
https://blog.csdn.net/akaks0/article/details/80039590
https://blog.csdn.net/lidew521/article/details/84661158