springCloud(十一) hystrix 超时设置

eureka:
  client:
    service-url:
      defaultZone:
        http://localhost:8761/eureka
spring:
  application:
    name: member-service
feign:
  hystrix:
    enabled: true
  client:
    config:
      default:
        connectTimeout: 1000      #两个微服务链接时间
        readTimeout: 5000   #链接后的处理时间
hystrix:
  command:
    #"类名#方法名(参数类型1,参数类型2,参数类型n)"   微服务局部处理
    "MessageService#sendSMS(String,String)": #HystrixCommandKey
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 1000   #熔断器熔断降级时间 设置要大于 connectTimeout + readTimeout 之和
            #假设:连接500毫秒,处理短信4000毫秒,哪个timeOut会触发服务降级
            # 链接   500毫秒 < connectTimeout 1000 正常;处理短信4000 < readTimeout 5000 正常; 但是 (4000 + 500) > 1000 超过了熔断时间。因此超时降级
      circuitBreaker:
        forceOpen: false #true代表强制熔断器强制处于Open状态,即服务不可用
        requestVolumeThreshold: 50
        errorThresholdPercentage: 60
        sleepWindowInMilliseconds: 10000
    # 全局默认的熔断设置
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 6000
      circuitBreaker:
        #在当20秒的时间内,最近50次调用请求,请求错误率超过60%,则触发熔断10秒,期间快速失败。
        requestVolumeThreshold: 50
        errorThresholdPercentage: 60
        sleepWindowInMilliseconds: 10000
      metrics:
        rollingStats:
          timeInMilliseconds: 20000

posted on 2020-06-26 10:42  顾~小诺  阅读(777)  评论(0编辑  收藏  举报

导航