HystrixCommandProperties命令執行相關配置:
hystrix.command.[commandkey].execution.isolation.strategy 隔離策略THREAD或SEMAPHORE 默認HystrixCommands使用THREAD方式 HystrixObservableCommands使用SEMAPHORE
hystrix.command.[commandkey].execution.timeout.enabled 是否開啟超時設置,默認true。
hystrix.command.[commandkey].execution.isolation.thread.timeoutInMilliseconds 默認超時時間 默認1000ms
hystrix.command.[commandkey].execution.isolation.thread.interruptOnTimeout是否打開超時線程中斷 默認值true
hystrix.command.[commandkey].execution.isolation.thread.interruptOnFutureCancel 當隔離策略為THREAD時,當執行線程執行超時時,是否進行中斷處理,即Future#cancel(true)處理,默認為false。
hystrix.command.[commandkey].execution.isolation.semaphore.maxConcurrentRequests 信號量最大並發度 默認值10該參數當使用ExecutionIsolationStrategy.SEMAPHORE策略時才有效。如果達到最大並發請求數,請求會被拒絕。理論上選擇semaphore size的原則和選擇thread size一致,但選用semaphore時每次執行的單元要比較小且執行速度快(ms級別),否則的話應該用thread。
hystrix.command.[commandkey].fallback.isolation.semaphore.maxConcurrentRequests fallback方法的信號量配置,配置getFallback方法並發請求的信號量,如果請求超過了並發信號量限制,則不再嘗試調用getFallback方法,而是快速失敗,默認信號量為10。
hystrix.command.[commandkey].fallback.enabled 是否啟用降級處理,如果啟用了,則在超時或異常時調用getFallback進行降級處理,默認開啟。
hystrix.command.[commandkey].circuitBreaker.enabled 是否開啟熔斷機制,默認為true。
hystrix.command.[commandkey].circuitBreaker.forceOpen 強制開啟熔斷,默認為false。
hystrix.command.[commandkey].circuitBreaker.forceClosed 強制關閉熔斷,默認為false。
hystrix.command.[commandkey].circuitBreaker.sleepWindowInMilliseconds 熔斷窗口時間,默認為5s。
hystrix.command.[commandkey].circuitBreaker.requestVolumeThreshold 當在配置時間窗口內達到此數量后的失敗,進行短路。默認20個
hystrix.command.[commandkey].circuitBreaker.errorThresholdPercentage 出錯百分比閾值,當達到此閾值后,開始短路。默認50%
hystrix.command.[commandkey].metrics.rollingStats.timeInMilliseconds 設置統計滾動窗口的長度,以毫秒為單位。用於監控和熔斷器 默認10s
hystrix.command.[commandkey].metrics.rollingStats.numBuckets 設置統計窗口的桶數量 默認10
hystrix.command.[commandkey].metrics.rollingPercentile.enabled 設置執行時間是否被跟蹤,並且計算各個百分比,50%,90%等的時間 默認true
hystrix.command.[commandkey].metrics.rollingPercentile.timeInMilliseconds 設置執行時間在滾動窗口中保留時間,用來計算百分比 默認60000ms
hystrix.command.[commandkey].metrics.rollingPercentile.numBuckets 設置rollingPercentile窗口的桶數量 默認6。
hystrix.command.[commandkey].metrics.rollingPercentile.bucketSize 此屬性設置每個桶保存的執行時間的最大值 默認100。如果bucket size=100,window=10s,若這10s里有500次執行,只有最后100次執行會被統計到bucket里去。增加該值會增加內存開銷以及排序的開銷。
hystrix.command.[commandkey].metrics.healthSnapshot.intervalInMilliseconds 記錄health 快照(用來統計成功和錯誤綠)的間隔,默認500ms
hystrix.command.[commandkey].requestCache.enabled 設置是否緩存請求,request-scope內緩存 默認值true
hystrix.command.[commandkey].requestLog.enabled 設置HystrixCommand執行和事件是否打印到HystrixRequestLog中 默認值true
hystrix.command.[commandkey].threadPoolKeyOverride 命令的線程池key,決定該命令使用哪個線程池。
HystrixThreadPoolProperties線程池相關配置:
hystrix.threadpool.[threadkey].coreSize 線程池核心線程數 默認值10;
hystrix.threadpool.[threadkey].maximumSize 線程池最大線程數 默認值10;
hystrix.threadpool.[threadkey].allowMaximumSizeToDivergeFromCoreSize 當線程數大於核心線程數時,是否需要回收。與keepAliveTimeMinutes配合使用。
hystrix.threadpool.[threadkey].keepAliveTimeMinutes 當實際線程數超過核心線程數時,線程存活時間 默認值1min
hystrix.threadpool.[threadkey].maxQueueSize 最大等待隊列數 默認不開啟使用SynchronousQueue 不可動態調整
hystrix.threadpool.[threadkey].queueSizeRejectionThreshold 允許在隊列中的等待的任務數量 默認值5
hystrix.threadpool.[threadkey].metrics.rollingStats.timeInMilliseconds 設置統計滾動窗口的長度,以毫秒為單位 默認值10000。
hystrix.threadpool.[threadkey].metrics.rollingStats.numBuckets 設置統計窗口的桶數量 默認10
HystrixCollapserProperties批處理相關配置:
hystrix.collapser.[collapserKey].maxRequestsInBatch 單次批處理的最大請求數,達到該數量觸發批處理,默認Integer.MAX_VALUE
hystrix.collapser.[collapserKey].timerDelayInMilliseconds 觸發批處理的延遲,也可以為創建批處理的時間+該值,默認值10
hystrix.collapser.[collapserKey].requestCache.enabled 默認值true
hystrix.collapser.[collapserKey].metrics.rollingStats.timeInMilliseconds 默認值10000
hystrix.collapser.[collapserKey].metrics.rollingStats.numBuckets 默認值10
hystrix.collapser.[collapserKey].metrics.rollingPercentile.enabled 默認值true
hystrix.collapser.[collapserKey].metrics.rollingPercentile.timeInMilliseconds 默認值60000
hystrix.collapser.[collapserKey].metrics.rollingPercentile.numBuckets 默認值6
hystrix.collapser.[collapserKey].metrics.rollingPercentile.bucketSize 默認值100