hystrix.command.default
和hystrix.threadpool.default
中的default
爲默認CommandKey
hystrix.command.default.execution.isolation.strategy
-----隔離策略,默認是Thread
, 可選Thread
|Semaphore
git
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds
------命令執行超時時間,默認1000ms
github
hystrix.command.default.execution.timeout.enabled
-----執行是否啓用超時,默認啓用true
hystrix.command.default.execution.isolation.thread.interruptOnTimeout
----- 發生超時是是否中斷,默true
hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests
----- 最大併發請求數,默認10,該參數當使用ExecutionIsolationStrategy.SEMAPHORE
策略時纔有效。若是達到最大併發請求數,請求會被拒絕。理論上選擇semaphore size
的原則和選擇thread size
一致,但選用semaphore
時每次執行的單元要比較小且執行速度快(ms級別),不然的話應該用thread
。semaphore應該佔整個容器(tomcat)的線程池的一小部分。緩存
Hystrix的THREAD
和SEMAPHORE
策略hystrix.command.default.fallback.isolation.semaphore.maxConcurrentRequests
----若是併發數達到該設置值,請求會被拒絕和拋出異常而且fallback不會被調用。默認10hystrix.command.default.fallback.enabled
----當執行失敗或者請求被拒絕,是否會嘗試調用hystrixCommand.getFallback()
。默認true
hystrix.command.default.circuitBreaker.enabled
----用來跟蹤circuit的健康性,若是未達標則讓request短路。默認true
hystrix.command.default.circuitBreaker.requestVolumeThreshold
----一個rolling window內最小的請求數。若是設爲20,那麼當一個rolling window的時間內(好比說1個rolling window是10秒)收到19個請求,即便19個請求都失敗,也不會觸發circuit break。默認20hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds
----觸發短路的時間值,當該值設爲5000時,則當觸發circuit break
後的5000毫秒內都會拒絕request,也就是5000毫秒後纔會關閉circuit。默認5000
hystrix.command.default.circuitBreaker.errorThresholdPercentage
----錯誤比率閥值,若是錯誤率>=該值,circuit會被打開,並短路全部請求觸發fallback。默認50hystrix.command.default.circuitBreaker.forceOpen
----強制打開熔斷器,若是打開這個開關,那麼拒絕全部request,默認false
hystrix.command.default.circuitBreaker.forceClosed
----強制關閉熔斷器 若是這個開關打開,circuit將一直關閉且忽略circuitBreaker.errorThresholdPercentage
hystrix.command.default.metrics.rollingStats.timeInMilliseconds
----設置統計的時間窗口值的,毫秒值,circuit break 的打開會根據1個rolling window的統計來計算。若rolling window被設爲10000毫秒,則rolling window會被分紅n個buckets,每一個bucket包含success,failure,timeout,rejection的次數的統計信息。默認10000hystrix.command.default.metrics.rollingStats.numBuckets
----設置一個rolling window被劃分的數量,若numBuckets=10,rolling window=10000,那麼一個bucket的時間即1秒。必須符合rolling window % numberBuckets == 0。默認10hystrix.command.default.metrics.rollingPercentile.enabled
---- 執行時是否enable指標的計算和跟蹤,默認truehystrix.command.default.metrics.rollingPercentile.timeInMilliseconds
---- 設置rolling percentile window的時間,默認60000hystrix.command.default.metrics.rollingPercentile.numBuckets
---- 設置rolling percentile window的numberBuckets。邏輯同上。默認6hystrix.command.default.metrics.rollingPercentile.bucketSize
---- 若是bucket size=100,window=10s,若這10s裏有500次執行,只有最後100次執行會被統計到bucket裏去。增長該值會增長內存開銷以及排序的開銷。默認100hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds
---- 記錄health 快照(用來統計成功和錯誤綠)的間隔,默認500mshystrix.command.default.requestCache.enabled
---- 默認true,須要重載getCacheKey(),返回null時不緩存hystrix.command.default.requestLog.enabled
----記錄日誌到HystrixRequestLog,默認truehystrix.collapser.default.maxRequestsInBatch
---- 單次批處理的最大請求數,達到該數量觸發批處理,默認Integer.MAX_VALUEhystrix.collapser.default.timerDelayInMilliseconds
---- 觸發批處理的延遲,也能夠爲建立批處理的時間+該值,默認10hystrix.collapser.default.requestCache.enabled
----是否對HystrixCollapser.execute() and HystrixCollapser.queue()的cache,默認true0.060+0.012
基本得原則是保持線程池儘量小,主要是爲了釋放壓力,防止資源被阻塞。當一切都是正常的時候,線程池通常僅會有1到2個線程激活來提供服務tomcat
hystrix.threadpool.default.coreSize
---- 併發執行的最大線程數,默認10hystrix.threadpool.default.maxQueueSize
---- BlockingQueue``的最大隊列數,當設爲-1,會使用SynchronousQueue
,值爲正時使用LinkedBlcokingQueue``。該設置只會在初始化時有效,以後不能修改threadpool
的queue size
,除非reinitialising thread executor
。默認-1。hystrix.threadpool.default.queueSizeRejectionThreshold
---- 排隊線程數量閾值,默認爲5,達到時拒絕,若是配置了該選項,隊列的大小是該隊列。注意:若是maxQueueSize=-1的話,則該選項不起做用。hystrix.threadpool.default.keepAliveTimeMinutes
---- 若是corePoolSize
和maxPoolSize
設成同樣(默認實現)該設置無效。若是經過plugin(https://github.com/Netflix/Hystrix/wiki/Plugins)
使用自定義實現,該設置纔有用,默認1.hystrix.threadpool.default.metrics.rollingStats.timeInMilliseconds
---- 線程池統計指標的時間,默認10000hystrix.threadpool.default.metrics.rollingStats.numBuckets
---- 將rolling window劃分爲n個buckets,默認10併發