Skip to content

Adaptive threshold

A static breaker compares the failure rate with a constant. fluxgo compares it with θₜ, a threshold recomputed from live latency.

R_ewma = St / Sbase EWMA ratio vs the healthy baseline
R_p = Pt / Pbase P95/P99 ratio vs the healthy baseline
Dt = W1·R_ewma + W2·R_p weighted degradation ratio
theta_t = clamp(ThetaBase / Dt, ThetaMin, ThetaMax)
SymbolMeaning
StCurrent EWMA latency, smoothed with Alpha
PtCurrent P95 (or P99) over the rolling window
Sbase, PbaseHealthy-state baselines captured during warmup
W1, W2Weights of the two signals; they must sum to 1
DtDegradation ratio: 1 means “as healthy as the baseline”
ThetaBaseThreshold used when latency equals the baseline
  • Latency doubles (Dt = 2): θₜ halves. With the default ThetaBase = 0.6 the 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.

  • 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.

Snapshot() exposes St, Pt, Dt, ThetaT and the baselines, so you can chart θₜ against the failure rate in your own monitoring.