Complete list of hystrix configurations
premise
Hystrix has stopped maintenance after November 20, 2018. The last submission record is: latest commit 3cb2158 on 20 Nov 2018, and the last official version is 1.5 18。 Since the current technology stack of the company is spring cloud, and the fuse and downgrade components mainly use hystrix, here is an analysis record of the complete list of hystrix, which can be queried at any time in the future. This article mainly refers to: hystrix configuration. Among them, command configuration is for hystrixcommand, mainly including command execution configuration, command fallback configuration, circuit breaker configuration, metrics configuration and request context configuration.
Hystrixcommandkey, hystrixcommandgroupkey, and hystrixthreadpoolkey
The three keys of hystrixcommandkey, hystrixcommandgroupkey and hystrixthreadpoolkey are important identifiers of hystrixcommand. Let's analyze their meanings respectively.
HystrixCommandKey
The hystrixcommandkey is the unique identifier of the hystrix command. Specifically, it is the unique identifier of the hystrixcommand instance or the hystrixobservercommand instance. It is required. If you do not customize the configuration, it will determine the default value in the following way:
[HystrixCommand或者HystrixObservableCommand的具体子类].getClass().getSimpleName();
The programming configuration is as follows:
HystrixCommandKey.Factory.asKey("Your Key");
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Group Key"))
.andCommandKey(HystrixCommandKey.Factory.asKey("Command Key")));
}
Note: most of the hystrix configurations are bound to the hystrix commandkey, so the hystrix commandkey is more important.
HystrixCommandGroupKey
The hystrixcommandgroupkey is used to group the hystrix commands. After grouping, it is convenient for statistics to be displayed on the dashboard, uploading reports and alerts. In other words, the hystrixcommandgroupkey is the grouping ID for measurement and statistics within the hystrix. The minimum dimension of data reporting and statistics is the grouping key. The hystrixcommandgroupkey must be configured as follows:
HystrixCommandGroupKey.Factory.asKey("Group Key")
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Group Key")));
}
HystrixThreadPoolKey
The hystrixthreadpoolkey mainly identifies the hystrixthreadpool instance used for monitoring, measurement, caching, and so on. A hystrixcommand is associated with an independent hystrixthreadpool instance, that is, a class of hystrixcommand is always executed in the same hystrixthreadpool instance. If the hystrixthreadpoolkey is not explicitly configured, the value of the hystrixcommandgroupkey will be used to configure the hystrixthreadpoolkey. The configuration method of hystrixthreadpoolkey is as follows:
HystrixThreadPoolKey.Factory.asKey("ThreadPoolKey")
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("xxx"))
.andCommandKey(HystrixCommandKey.Factory.asKey("YYY"))
.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey("ThreadPoolKey")));
}
Command execution configuration
Isolation strategy
The isolation policy determines what type of policy is used for dependency isolation when the hystrix command is executed.
Whether thread pool (thread) or semaphore (semaphore) is selected to implement the isolation policy? The suggestions given in the document are:
What I want to say is: it is recommended to use the default value, because there are few scenarios using semaphore isolation at present.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.strategy=THREAD
# 实例配置
hystrix.command.CustomCommand.execution.isolation.strategy=THREAD
Allow timeout
Determines whether timeout is allowed during the execution of hystrixcommand#run(). The "timeout upper limit" mentioned below will be valid only when it is set to true.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.timeout.enabled=true
# 实例配置
hystrix.command.CustomCommand.execution.timeout.enabled=true
The maximum timeout limit of hystrix command execution, in milliseconds. If the command execution time exceeds this time value, it will enter the degradation logic. The prerequisite for this configuration to take effect is hystrix command. default. execution. timeout. Enabled or hystrix command. [HystrixCommandKey]. execution. timeout. Enabled is true.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(1000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.timeoutInMilliseconds=1000
Is the timeout interrupted
This configuration item determines whether to interrupt when the call of hystrixcommand#run() times out.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationThreadInterruptOnTimeout(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.interruptOnTimeout=true
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.interruptOnTimeout=true
Cancel interrupt
This configuration item determines whether to interrupt when the call is cancelled during the execution of hystrixcommand#run().
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationThreadInterruptOnFutureCancel(false)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.interruptOnCancel=false
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.interruptOnCancel=false
Maximum concurrent request limit (semaphore)
This configuration item decides to use the hystrixcommand#run () method and executionisolationstrategy The maximum number of concurrent requests under the semaphore isolation policy.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests=100
# 实例配置
hystrix.command.CustomCommand.execution.isolation.semaphore.maxConcurrentRequests=100
Command fallback configuration
The command degradation configuration controls the execution logic of hystrixcommand#getfallback(), and all command degradation configurations affect the policy executionisolationstrategy Thread or executionisolationstrategy Semaphore is in effect.
Maximum concurrent degradation request processing limit
This property is used to control the maximum upper limit of a HystrixCommand#getFallback () instance method in the execution thread. If this limit is exceeded, the degraded logic will not execute and an exception will be thrown.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withFallbackIsolationSemaphoreMaxConcurrentRequests(20)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.fallback.isolation.semaphore.maxConcurrentRequests=20
# 实例配置
hystrix.command.CustomCommand.fallback.isolation.semaphore.maxConcurrentRequests=20
Enable demotion
This property controls whether to call hystrixcommand #getfallback() after the execution of hystrixcommand fails.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withFallbackEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.fallback.enabled=true
# 实例配置
hystrix.command.CustomCommand.fallback.enabled=true
Circuit breaker configuration
The circuit breaker configuration is used to control the behavior of the hystrixcircuitbreaker instance.
Is the circuit breaker enabled
This attribute determines whether the circuit breaker is used to track health status and whether it is used for short circuit requests when the circuit breaker is open (making requests fail quickly into degraded logic).
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.enabled=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.enabled=true
Circuit breaker request threshold
This property sets the minimum number of requests in the sliding window that will open the circuit breaker.
For example, if the value is 20, if only 19 requests (such as a 10 second window) are received in the sliding window, the circuit breaker will not open even if all 19 requests fail.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerRequestVolumeThreshold(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.requestVolumeThreshold=10
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.requestVolumeThreshold=10
Circuit breaker waiting window time
This property sets the amount of time a request is rejected after the circuit breaker is opened. Every other period of time (sleepwindowinmilliseconds) allows another attempt (that is, releasing a request) to determine whether the circuit breaker should be closed.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerSleepWindowInMilliseconds(5000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds=5000
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.sleepWindowInMilliseconds=5000
Circuit breaker error percentage threshold
This property sets an error percentage. When the request error rate exceeds the set value, the circuit breaker will open.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerErrorThresholdPercentage(50)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.errorThresholdPercentage=50
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.errorThresholdPercentage=50
be careful:
Is the circuit breaker forced to open
This attribute controls whether the circuit breaker is forcibly opened. Forcibly opening the circuit breaker will make all requests directly enter the degraded logic, that is, the logic wrapped in hystrixcommand#run() will not be executed. circuitBreaker. Forceopen property and circuitbreaker The forceclosed property is mutually exclusive.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerForceOpen(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.forceOpen=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.forceOpen=true
Is the circuit breaker forced off
This attribute controls whether the circuit breaker is forcibly closed. Forcibly closing the circuit breaker will cause all configurations and functions related to the circuit breaker to fail, and the exception thrown by hystrixcommand#run() will normally enter the degradation logic. circuitBreaker. Forceclosed property and circuitbreaker The forceopen property is mutually exclusive.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerForceClosed(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.forceClosed=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.forceClosed=true
Metrics configuration
The measurement statistics configuration will take effect on the statistics collection action when the hystrixcommand or hystrixobservercommand is executed.
Sliding window duration
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingStatisticalWindowInMilliseconds(10000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingStats.timeInMilliseconds=10000
# 实例配置
hystrix.command.CustomCommand.metrics.rollingStats.timeInMilliseconds=10000
Total number of sliding window buckets
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingStatisticalWindowBuckets(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingStats.numBuckets=10
# 实例配置
hystrix.command.CustomCommand.metrics.rollingStats.numBuckets=10
Enable percentage calculation
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingpercentileEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingpercentile.enabled=true
# 实例配置
hystrix.command.CustomCommand.metrics.rollingpercentile.enabled=true
Sliding window duration used for percentage calculation
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingpercentileWindowInMilliseconds(60000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingpercentile.timeInMilliseconds=60000
# 实例配置
hystrix.command.CustomCommand.metrics.rollingpercentile.timeInMilliseconds=60000
Total number of buckets used for percentage calculation
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingpercentileWindowBuckets(6)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingpercentile.numBuckets=6
# 实例配置
hystrix.command.CustomCommand.metrics.rollingpercentile.numBuckets=6
Bucket capacity used for percentage calculation
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingpercentileBucketSize(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingpercentile.bucketSize=100
# 实例配置
hystrix.command.CustomCommand.metrics.rollingpercentile.bucketSize=100
Cycle of health snapshot collection
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsHealthSnapshotIntervalInMilliseconds(500)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=500
# 实例配置
hystrix.command.CustomCommand.metrics.healthSnapshot.intervalInMilliseconds=500
Request context configuration
The request context attribute mainly involves the use of hystrixrequestcontext and hystrixcommand.
Enable request caching
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.requestCache.enabled=true
# 实例配置
hystrix.command.CustomCommand.requestCache.enabled=true
Enable request logging
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withRequestLogEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.requestLog.enabled=true
# 实例配置
hystrix.command.CustomCommand.requestLog.enabled=true
Request synthesizer configuration
The request synthesizer configuration mainly controls the behavior of the hystrixcollapser.
Maximum number of batches requested to be synthesized
Programming configuration:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>,String,String> {
public CustomHystrixCollapser(Setter setter) {
super(Setter.withCollapserKey(HystrixCollapserKey.Factory.asKey("CustomHystrixCollapser"))
.andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter()
.withMaxRequestsInBatch(10)));
}
@Override
public String getRequestArgument() {
return null;
}
@Override
protected HystrixCommand<List<String>> createCommand(Collection<CollapsedRequest<String,String>> collapsedRequests) {
return null;
}
@Override
protected void mapResponseToRequests(List<String> batchResponse,Collection<CollapsedRequest<String,String>> collapsedRequests) {
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.maxRequestsInBatch=10
# 实例配置
hystrix.collapser.CustomHystrixCollapser.maxRequestsInBatch=10
Delayed execution time
Programming configuration:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>,String> {
public CustomHystrixCollapser(Setter setter) {
super(Setter.withCollapserKey(HystrixCollapserKey.Factory.asKey("CustomHystrixCollapser"))
.andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter()
.withTimerDelayInMilliseconds(10)));
}
@Override
public String getRequestArgument() {
return null;
}
@Override
protected HystrixCommand<List<String>> createCommand(Collection<CollapsedRequest<String,String>> collapsedRequests) {
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.timerDelayInMilliseconds=10
# 实例配置
hystrix.collapser.CustomHystrixCollapser.timerDelayInMilliseconds=10
Enable request composition caching
Programming configuration:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>,String>> collapsedRequests) {
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.requestCache.enabled=true
# 实例配置
hystrix.collapser.CustomHystrixCollapser.requestCache.enabled=true
Thread pool configuration
Hystrix uses the JUC thread pool ThreadPoolExecutor, and the thread pool related configuration directly affects the ThreadPoolExecutor instance. The command execution of hystrix adopts the thread pool strategy, so it is executed separately through the thread pool. It is best to set up an independent thread pool for each group. In production practice, the author generally sets the hystrixcommandgroupkey and hystrixthreadpoolkey to be consistent.
Number of core threads
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withCoreSize(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.coreSize=10
# 实例配置
hystrix.threadpool.CustomCommand.coreSize=10
Maximum number of threads
This property takes effect only when allowmaximumsizetodiversgefromcoresize is true.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMaximumSize(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.maximumSize=10
# 实例配置
hystrix.threadpool.CustomCommand.maximumSize=10
Maximum task queue capacity
When this property is configured as - 1, it uses synchronousqueue, and when it is configured as an integer greater than 1, it uses linkedblockingqueue.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMaxQueueSize(-1)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.maxQueueSize=-1
# 实例配置
hystrix.threadpool.CustomCommand.maxQueueSize=-1
Task queue threshold for task rejection
When maxqueuesize is configured to - 1, this configuration item does not take effect.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withQueueSizeRejectionThreshold(5)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.queueSizeRejectionThreshold=5
# 实例配置
hystrix.threadpool.CustomCommand.queueSizeRejectionThreshold=5
Non core thread lifetime
This configuration takes effect only when allowmaximumsizetodiversgefromcoresize is true and maximumsize is greater than coresize.
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withKeepAliveTimeMinutes(1)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.keepAliveTimeMinutes=1
# 实例配置
hystrix.threadpool.CustomCommand.keepAliveTimeMinutes=1
Allow maximum threads to take effect
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withAllowMaximumSizeToDivergeFromCoreSize(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.allowMaximumSizeToDivergeFromCoreSize=true
# 实例配置
hystrix.threadpool.CustomCommand.allowMaximumSizeToDivergeFromCoreSize=true
Thread pool sliding window duration
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMetricsRollingStatisticalWindowInMilliseconds(10000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.metrics.rollingStats.timeInMilliseconds=10000
# 实例配置
hystrix.threadpool.CustomCommand.metrics.rollingStats.timeInMilliseconds=10000
Total number of thread pool sliding window buckets
Programming configuration:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMetricsRollingStatisticalWindowBuckets(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
Properties in the configuration file:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.metrics.rollingStats.numBuckets=10
# 实例配置
hystrix.threadpool.CustomCommand.metrics.rollingStats.numBuckets=10
Original link
(end of this paper e-a-201890602 1:00 am c-3-d)
The official account of Technology (Throwable Digest), which is not regularly pushed to the original technical article (never copied or copied):
Entertainment official account ("sand sculpture"), select interesting sand sculptures, videos and videos, push them to relieve life and work stress.