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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM