Detailed explanation of Spring Cloud Hystrix configuration content

Command Properties

The following properties control HystrixCommand behavior:

Execution

The following properties control how HystrixCommand.run() executes.

For source code and default parameters, refer to the HystrixCommandProperties class.

parameter

describe

Defaults

execution.isolation.strategy

Isolation strategy, there are THREAD and SEMAPHORE

THREAD - it executes on a separate thread, concurrent requests are limited by the number of threads in the thread pool
SEMAPHORE - it executes on the calling thread, concurrent requests are limited by the semaphore count

The THREAD mode is used by default, and the SEMAPHORE mode can be used in the following scenarios:

Just want to control the degree of concurrency

External methods have been thread-isolated

The call is a local method or a very reliable and time-consuming method (such as medis)

 

execution.isolation.thread.timeoutInMilliseconds

overtime time

Default: 1000

In THREAD mode, when the timeout period is reached, it can be interrupted

In SEMAPHORE mode, it will wait for the execution to complete before judging whether it times out

Set the standard:

有retry,99meantime+avg meantime

No retry, 99.5 mean time

 

execution.timeout.enabled

Whether HystrixCommand.run() execution should have a timeout.

Default: true

execution.isolation.thread.interruptOnTimeout

Whether HystrixCommand.run() execution should be interrupted when a timeout occurs.

Default: true

THREAD mode is valid

execution.isolation.thread.interruptOnCancel

Whether execution should be interrupted when cancellation occurs.

The default value is false

THREAD mode is valid

execution.isolation.semaphore.maxConcurrentRequests

Sets the maximum number of requests allowed to the HystrixCommand.run() method when used.

Default: 10

SEMAPHORE mode valid

Fallback

The following properties control how HystrixCommand.getFallback() executes. These properties apply to ExecutionIsolationStrategy.THREAD and ExecutionIsolationStrategy.SEMAPHORE.

For source code and default parameters, refer to the HystrixCommandProperties class.

parameter

describe

Defaults

fallback.isolation.semaphore.maxConcurrentRequests

Sets the maximum number of requests allowed to the HystrixCommand.getFallback() method from the calling thread.

SEMAPHORE mode valid

Default: 10

fallback.enabled

Determines whether to attempt to call HystrixCommand.getFallback() when a failure or rejection occurs.

The default value is true

 

Circuit Breaker

The circuit breaker property controls the behavior of HystrixCircuitBreaker.

For source code and default parameters, refer to the HystrixCommandProperties class.

parameter

describe

Defaults

circuitBreaker.enabled

Determines if the circuit breaker is used to track health and short circuit requests (if tripped).

The default value is true

circuitBreaker.requestVolumeThreshold

The minimum number of fuse triggers/10s

Default: 20

circuitBreaker.sleepWindowInMilliseconds

How many seconds after fusing to try the request

Default: 5000

circuitBreaker.errorThresholdPercentage

When the failure rate reaches a certain percentage, it will be blown

Default: 50

Mainly adjusted according to dependency importance

 

circuitBreaker.forceOpen

 

Property If true, forces the circuit breaker into the open (tripped) state, where it will deny all requests.

The default value is false

This property takes precedence over circuitBreaker.forceClosed

circuitBreaker.forceClosed

This property, if true, forces the circuit breaker into a closed state, where it will allow requests regardless of error percentage.

The default value is false

If it is a strong dependency, it should be set to true

circuitBreaker.forceOpen属性优先,因此如果forceOpen设置为true,此属性不执行任何操作。

Metrics

参数

描述

默认值

metrics.rollingStats.timeInMilliseconds

此属性设置统计滚动窗口的持续时间(以毫秒为单位)。对于断路器的使用和发布Hystrix保持多长时间的指标。

默认值:10000

metrics.rollingStats.numBuckets

此属性设置rollingstatistical窗口划分的桶数。

以下必须为true - “metrics.rollingStats.timeInMilliseconds%metrics.rollingStats.numBuckets == 0” -否则将抛出异常。

默认值:10

metrics.rollingPercentile.enabled

此属性指示是否应以百分位数跟踪和计算执行延迟。 如果禁用它们,则所有摘要统计信息(平均值,百分位数)都将返回-1。

默认值为true

metrics.rollingPercentile.timeInMilliseconds

 

此属性设置滚动窗口的持续时间,其中保留执行时间以允许百分位数计算,以毫秒为单位。

默认值:60000

metrics.rollingPercentile.numBuckets

此属性设置rollingPercentile窗口将划分的桶的数量。

以下内容必须为true - “metrics.rollingPercentile.timeInMilliseconds%metrics.rollingPercentile.numBuckets == 0” -否则将抛出异常。

默认值:6

metrics.rollingPercentile.bucketSize

此属性设置每个存储桶保留的最大执行次数。如果在这段时间内发生更多的执行,它们将绕回并开始在桶的开始处重写。

默认值:100

metrics.healthSnapshot.intervalInMilliseconds

此属性设置在允许计算成功和错误百分比并影响断路器状态的健康快照之间等待的时间(以毫秒为单位)。

默认值:500

 

Request Context

这些属性涉及HystrixCommand使用的HystrixRequestContext功能。

 

参数

描述

默认值

requestCache.enabled

HystrixCommand.getCacheKey()是否应与HystrixRequestCache一起使用,以通过请求范围的缓存提供重复数据删除功能。

默认值为true

requestLog.enabled

HystrixCommand执行和事件是否应记录到HystrixRequestLog。

默认值为true

 

Collapser Properties

源码类及默认参数HystrixCollapserProperties类

下列属性控制HystrixCollapser行为。

参数

描述

默认值

maxRequestsInBatch

 

此属性设置在触发批处理执行之前批处理中允许的最大请求数。

Integer.MAX_VALUE

timerDelayInMilliseconds

 

此属性设置创建批处理后触发其执行的毫秒数。

默认值:10

requestCache.enabled

 

此属性指示是否为HystrixCollapser.execute()和HystrixCollapser.queue()调用启用请求高速缓存。

默认值:true

 

ThreadPool Properties

以下属性控制Hystrix命令在其上执行的线程池的行为。

源码类及默认参数HystrixThreadPoolProperties类

参数

描述

默认值

coreSize

线程池coreSize

默认值:10

设置标准:qps*99meantime+breathing room

maximumSize

此属性设置最大线程池大小。 这是在不开始拒绝HystrixCommands的情况下可以支持的最大并发数。 请注意,此设置仅在您还设置allowMaximumSizeToDivergeFromCoreSize时才会生效。

默认值:10

maxQueueSize

请求等待队列

默认值:-1

如果使用正数,队列将从SynchronizeQueue改为LinkedBlockingQueue

queueSizeRejectionThreshold

此属性设置队列大小拒绝阈值 - 即使未达到maxQueueSize也将发生拒绝的人为最大队列大小。 此属性存在,因为BlockingQueue的maxQueueSize不能动态更改,我们希望允许您动态更改影响拒绝的队列大小。

默认值:5

注意:如果maxQueueSize == -1,则此属性不适用。

keepAliveTimeMinutes

此属性设置保持活动时间,以分钟为单位。

默认值:1

allowMaximumSizeToDivergeFromCoreSize

此属性允许maximumSize的配置生效。 那么该值可以等于或高于coreSize。 设置coreSize <maximumSize会创建一个线程池,该线程池可以支持maximumSize并发,但在相对不活动期间将向系统返回线程。 (以keepAliveTimeInMinutes为准)

默认值:false

metrics.rollingStats.timeInMilliseconds

此属性设置statistical rolling窗口的持续时间(以毫秒为单位)。 这是为线程池保留多长时间。

默认值:10000

metrics.rollingStats.numBuckets

此属性设置滚动统计窗口划分的桶数。
注意:以下必须为true - “metrics.rollingStats.timeInMilliseconds%metrics.rollingStats.numBuckets == 0” -否则将引发异常。

默认值:10

 

Guess you like

Origin blog.csdn.net/yytree123/article/details/108438758