The Soul gateway stream limiting plug-ins Sentinel and Resilience4J for literacy

Soul Gateway stream limiting plugin Sentinel literacy

Let’s start with the items Sebtinel can configure in SoulMeaning of the corresponding configuration

  • Degrade count: the fuse threshold

  • Degrade (1 or 0) : whether to open the fuse (1 or 0

  • Degrade type: Fuse type,slow Call ratio(RT), exception ratio, exception number strategy (minute number of exceptions)

  • Degrade window size: the unit is s

  • Control behavior: warm up (warm/cold start mode, with slow increase of traffic), Constant speed queuing (uniform queuing), preheating queued

  • Grade Count: indicates the traffic limiting threshold

  • Whether Control behavior is enabled (1 or 0) : Indicates whether traffic limiting is enabled

  • Grade Type: QPS, number of Concurrent Threads

However, it can be seen from the meanings of the interface and parameters that, in fact, the opening of the fuse switch and current limiting has an impact on the setting of other parameters, but the interface popup window does not reflect this. According to the ideal state, the other fuse parameters should be displayed after the fuse switch is turned on, and the same is true for current limiting. Degrade the value of whether to open the degrade by using numbers. I think it needs to be adjusted.. As you can see in the code, the fuses or current limiting switches are turned on before the relevant configuration is loaded

Soul Gateway Flow limiting plugin Resilience4J for literacy

Again, look first at the items that Resilience4J can configure in the Soul gateway

  • Token Filling Period (ms) : Interval for refreshing tokens, in ms. Default: 500.

  • Token Filling Number: Number of refreshing tokens each time. Default value: 50.

  • Control Behavior Timeout (ms) : Duration for stopping the external service (unit: ms)

  • Circuit enable: indicates whether to enable the circuit breaker. 0: indicates that the circuit breaker is disabled. 1: indicates that the circuit breaker is enabled.

  • Circuit timeout (ms) : indicates the timeout period for a circuit breaker. If a service response exceeds this timeout, a circuit breaker is triggered, expressed in ms. Default value: 30000.

  • Fallback URI: INDICATES the URI of degraded processing.

  • Sliding window size: indicates the sliding window size. Default value: 100.

  • Sliding window type: indicates the sliding window type. 0: indicates the count based. 1: indicates the time based.

  • Enabled Error minimum Calculation threshold: indicates the minimum number of requests for the fuse to be enabled. If the number of requests exceeds this threshold, fuse statistics will be enabled. The default value is 100.

  • Degrade opening duration: The unit is ms. Default value: 10

  • Half open threshold: size of the circular buffer in the half open state. This value must be reached before the failure rate can be calculated. Default value: 10.

  • Degrade failure rate: the threshold at which fuses turn on. The default value is 50.

And you can see that this is also the case where the fuse is turned on to load some configuration, and you can see that the magic number of the two ones here can actually be changed to a fixed parameter like Sentinel. Of course I feel it would be better to set it to true or false and look forward to an orderly optimization. Another parameter that you can focus on is the half-open state, because you don’t understand the half-open state. So I looked it up on the Internet, and the description is as follows

CircuitBreaker state transitions are implemented through a finite state machine, which has three common states: CLOSED, OPEN, half-open, and two specific states: DISABLED, FORCE_OPEN.

  • CLOSED ==> OPEN: one-way conversion. When the request failure rate exceeds the threshold, the state of the fuse changes from off to on. The default failure threshold is 50%, which can be changed by setting failureRateThreshold of the CircuitBreakerConfig instance.
  • OPEN <==> HALF_OPEN: bidirectional conversion. When the duration of the open state ends, the fuse switches from the open state to the half open state. A certain number of requests are allowed to pass. When the failure rate of these requests exceeds the threshold, the state of the fuse changes from half-open to open. When half the number of requests by CircuitBreakerConfig instance ringBufferSizeInHalfOpenState attribute value is set.
  • HALF_OPEN ==> CLOSED: If the request failure rate is lower than the threshold, the fuse is switched from half-open to CLOSED.
  • The DISABLED and FORCE_OPEN states are only critical state indicators for exiting the preceding three states. These two states are not recorded in the statistics and state transition events are not sent.

The transformation relationship is shown below

I think the optimizable term

  • Other configuration items are shown according to the Settings of fuses or current limiting switches
  • Remove magic number 1 and set the switch item to true or false.

Welcome to search attention to my public number [micro view technology], and summary of classified interview questions github.com/zhendiao/Ja…