16.Hystrix -电商系统集成Hystrix(配置文件级别

2020-06-07  本文已影响0人  溅十三

1.@HystrixCommand方式呢,很污染代码,将Hystrix的配置装移到yaml当中

loginFail与登录的降级熔断一致,一一对应就好

hystrix:
  command:
    # 有的属性是默认值,写不写都行
    default:
      fallback:
        enabled: true
      circuitBreaker:
        enabled: true
        # 超过50%错误,那么开启熔断
        errorThresholdPercentage: 50
        # 5个request之后才进行统计
        requestVolumeThreshold: 5
        # 10秒之后进入半开状态
        sleepWindowInMilliseconds: 10000
        # forceClosed, forceOpen 强制关闭/开启熔断开关
      execution:
        timeout:
          enabled: true
        # 可以指定隔离方式是线程池还是信号量
        isolation:
          thread:
            interruptOnTimeout: true
            interruptOnFutureCancel: true
            timeoutInMilliseconds: 10000
      metrics:
        rollingStats:
          # 时间窗口统计
          timeInMilliseconds: 20000
          # numBuckets: 10
    #        rollingPercentile:
    #          # 时间窗口统计
    #          timeInMilliseconds: 20000
    #          # numBuckets: 10
    #          bucketSize: 300
    # 照这个方法,覆盖其他的属性
    loginFail:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 3000
上一篇 下一篇

猜你喜欢

热点阅读