You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Rejection rate increases when the service is unhealthy
626
-
- Rejection rate decreases when the service recovers
627
-
- The system finds an equilibrium that protects against cascading failures while allowing recovery
639
+
Or, more simply, if you define `delta_error = error_rate - ideal_error_rate` then:
628
640
629
-
##### Adaptive Circuit Breaker Configuration
641
+
```
642
+
P = delta_error - (1 - delta_error) * rejection_rate
643
+
```
644
+
645
+
In simple terms: This equation says: open more when the error rate is higher than the rejection rate,
646
+
and less when the opposite. The multiplier of `(1 - delta_error)` is called the aggressiveness multiplier.
647
+
It allows the circuit to open more aggressively depending on how bad the situation is.
630
648
631
-
To enable the adaptive circuit breaker, simply set:
649
+
This P is fed into a typical PID equation, and is used to control the rejection rate of the circuit breaker.
650
+
651
+
##### Adaptive Circuit Breaker Configuration
632
652
633
-
- **adaptive_circuit_breaker**. Enable adaptive circuit breaker instead of traditional. Defaults to `false`.
653
+
To enable the adaptive circuit breaker, simply set **adaptive_circuit_breaker** to true.
634
654
635
655
Example configuration:
636
656
```ruby
@@ -641,15 +661,23 @@ Semian.register(
641
661
)
642
662
```
643
663
644
-
The adaptive circuit breaker uses carefully tuned internal parameters based on extensive testing:
645
-
- PID controller gains optimized for stability and responsiveness
646
-
- 10-second window for rate calculations
647
-
- 1-hour history for ideal error rate calculation (p90)
648
-
- 1-second interval for background health checks
649
-
650
664
**Note**: When `adaptive_circuit_breaker: true` is set, traditional circuit breaker
651
665
parameters (`error_threshold`, `error_timeout`, etc.) are ignored.
652
666
667
+
668
+
We **_highly_** recommend just setting that configuration and not any other.
669
+
One of the main goals of the adaptive circuit breaker is that it "just works".
670
+
Configuring it might be difficult and not provide much value. That said, here are the configurations you can set:
671
+
* **kp:** The contribution of P in the PID equation. Increasing it means you react more quickly to the latest data. Defaults to 1.0
672
+
* **ki**: The contribution of the integral in the PID equation. Increasing it means adding more "memory", which is useful to ignoring noise. Defaults to 0.2
673
+
* **kd**: The contribution of the derivative in the PID equation. Its behaviour can be complex because of our complex P equation. Defaults to 0.0
674
+
* **integral_upper_cap**: Maximum value of the integral, prevents integral windup. Default to 10.0
675
+
* **integral_lower_cap**: Minimum value of the integral, prevents integral windup. Default to -10.0
676
+
* **window_size**: How many seconds of observations to take into account. Note that this window is a sliding window of 1 second sliding interval. To control the sliding interval you should set the environment variable SEMIAN_ADAPTIVE_CIRCUIT_BREAKER_SLIDING_INTERVAL (shared among all adaptive circuit breakers). window_size default to 10 seconds
677
+
* **dead_zone_ratio**: An error percentage above the ideal_error_rate to ignore. This helps remove noise. Defaults to 0.25
678
+
* **initial_error_rate**: The guess to start with for the ideal error rate. Defaults to 0.05 (5%)
679
+
* **ideal_error_rate_estimator_cap_value**: The value above which we ignore observations for the ideal error rate. Defaults to 0.1 (10%)
680
+
653
681
### Bulkheading
654
682
655
683
For some applications, circuit breakers are not enough. This is best illustrated
0 commit comments