Adaptive threshold
A static breaker compares the failure rate with a constant. fluxgo compares it with θₜ, a threshold recomputed from live latency.
The formula
Section titled “The formula”R_ewma = St / Sbase EWMA ratio vs the healthy baselineR_p = Pt / Pbase P95/P99 ratio vs the healthy baselineDt = W1·R_ewma + W2·R_p weighted degradation ratiotheta_t = clamp(ThetaBase / Dt, ThetaMin, ThetaMax)| Symbol | Meaning |
|---|---|
St | Current EWMA latency, smoothed with Alpha |
Pt | Current P95 (or P99) over the rolling window |
Sbase, Pbase | Healthy-state baselines captured during warmup |
W1, W2 | Weights of the two signals; they must sum to 1 |
Dt | Degradation ratio: 1 means “as healthy as the baseline” |
ThetaBase | Threshold used when latency equals the baseline |
What it does in practice
Section titled “What it does in practice”- Latency doubles (
Dt = 2): θₜ halves. With the defaultThetaBase = 0.6the circuit opens at a 30% failure rate instead of 60%. - Latency improves (
Dt < 1): θₜ rises, so the circuit tolerates more failures before opening. - Clamping keeps θₜ inside
[ThetaMin, ThetaMax](default[0.05, 0.9]), so a single outlier cannot make the breaker either trigger-happy or deaf.
The circuit opens when the failure rate in the outcome window reaches θₜ, and
only once the window holds at least MinRequests outcomes.
Why two signals
Section titled “Why two signals”- EWMA reacts smoothly to a shift of the average latency.
- P95/P99 reacts to the tail, which is where a degrading dependency shows up first.
W1 = 0.4 and W2 = 0.6 weight the tail slightly more. Setting W1 = 1 uses
only the average; W2 = 1 uses only the percentile.
Watching it live
Section titled “Watching it live”Snapshot() exposes St, Pt, Dt, ThetaT and
the baselines, so you can chart θₜ against the failure rate in your own
monitoring.