com.feingto.cloud.constants.HystrixConstants Maven / Gradle / Ivy
package com.feingto.cloud.constants;
/**
* 熔断相关默认配置
*
* @author longfei
*/
public class HystrixConstants {
// 线程池基本大小, 默认值: 10(请求高峰时99.5%的平均响应时间 + 向上预留)
public static final int coreSize = 50;
// 线程池最大线程数, 默认值: 10
public static final int maximumSize = 5000;
// 等待队列最大长度, 默认-1(不等待直接拒绝), 使用SynchronousQueue, 否则使用LinkedBlockingQueue
// 若要动态调整则需重启, 需要使用queueSizeRejectionThreshold配置
// 测试表明线程池使用直接决绝策略 + 合适大小的非回缩线程池效率最高, 不建议修改
public static final int maxQueueSize = -1;
// 排队线程数量阈值,默认为5,达到时拒绝,如果配置了该选项,队列的大小是该队列(注意:如果maxQueueSize=-1的话,则该选项不起作用)
public static final int queueSizeRejectionThreshold = 5;
// 是否启用断路器, 默认值: true
public static final Boolean circuitBreakerEnabled = true;
// 10000 = 10 seconds (and default of 10 buckets so each bucket is 1 second)
public static final Integer metricsRollingStatisticalWindowInMilliseconds = 10000;
// 10 = 10 buckets in a 10 second window so each bucket is 1 second
public static final Integer metricsRollingStatisticalWindowBuckets = 10;
// 熔断触发的最小个数/10s, 默认值: 20次
public static final Integer circuitBreakerRequestVolumeThreshold = 20;
// 熔断多少秒后去尝试请求, 默认值: 5秒
public static final Integer circuitBreakerSleepWindowInMilliseconds = 5000;
// 失败率达到多少百分比后熔断, 默认值: 50
public static final Integer circuitBreakerErrorThresholdPercentage = 50;
// 是否强制断路器进入打开(跳闸)状态,其中它将拒绝所有请求, 默认值: false, 此属性优先于circuitBreaker.forceClosed
public static final boolean circuitBreakerForceOpen = false;
// 是否迫使断路器进入闭合状态,其中它将允许请求,而不考虑误差百分比, 默认值: false,
// 如果是强依赖,应该设置为true, circuitBreaker.forceOpen属性优先,因此如果forceOpen设置为true,此属性不执行任何操作
public static final boolean circuitBreakerForceClosed = false;
// 使用信号量隔离时命令调用最大的并发数, 默认值: 10
public static final Integer executionIsolationSemaphoreMaxConcurrentRequests = 5000;
// 使用线程隔离时是否对命令执行超时的线程调用中断 Thread.interrupt() 操作. 默认值: true
public static final Boolean executionIsolationThreadInterruptOnTimeout = true;
// 线程调用中断 Thread.interrupt() 操作时是否取消命令
public static final Boolean executionIsolationThreadInterruptOnFutureCancel = false;
// 是否启用调用超时
public static final Boolean executionTimeoutEnabled = true;
// 调用超时时间, 默认值: 1秒
public static final Integer executionTimeoutInMilliseconds = 60000;
// 是否开启fallback降级策略
public static final Boolean fallbackEnabled = true;
// 命令fallback(降级)调用最大的并发数, 默认值: 10
public static final Integer fallbackIsolationSemaphoreMaxConcurrentRequests = 500;
// 是否开启监控统计功能, 默认值: true
public static final Boolean metricsRollingPercentileEnabled = true;
// 统计滚动的时间窗口, 默认值: 500毫秒
public static final Integer metricsHealthSnapshotIntervalInMilliseconds = 500;
// 统计窗口的Buckets的数量, 默认值: 6个, 每秒一个Buckets统计
public static final Integer metricsRollingPercentileWindowBuckets = 6;
// Buckets 最大值, 默认值: 100
public static final Integer metricsRollingPercentileBucketSize = 100;
// default to 1 minute for RollingPercentile
public static final Integer metricsRollingPercentileWindowInMilliseconds = 60000;
// 是否开启请求缓存, 默认值: true
public static final Boolean requestCacheEnabled = true;
// 是否开启请求日志, 默认值: true
public static final Boolean requestLogEnabled = true;
// 时间间隔在10ms之内的请求合并为一个请求, 默认值: 10ms
public static final Integer collapserTimerDelayInMilliseconds = 10;
// 时间间隔内合并的最大请求数
public static final Integer collapserMaxRequestsInBatch = 10;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy