Skip to content

Circuit breaker

Definition

The circuit breaker stops routing traffic to a provider that fails repeatedly. While the breaker is open, the gateway skips that provider instead of letting every request fail against it.

Function

Without a breaker, every request in a provider outage first fails against that provider and only then falls back. The breaker counts failures, opens when the failure threshold is reached, and sends traffic to the remaining healthy targets at once. This keeps latency stable during a provider incident.

Rules and facts

  • The breaker is enabled per gateway. It is inactive until an administrator turns it on.
  • State is tracked per provider on each gateway. One failing provider does not affect the others.
  • The built-in Myra model fleet is tracked per model. Each Myra model has the gateway's own breaker plus one breaker shared by all gateways. The shared breaker reacts only to failures from more than one tenant, so one tenant can never take a model offline for others.
  • The breaker has three states:
    • Closed — healthy; requests route normally.
    • Open — requests skip the provider.
    • Half-open — after the cooldown, probe requests test recovery. A real answer closes the breaker; a failure re-opens it; an empty or cancelled attempt counts as neither.
  • Server errors, connection errors and timeouts count as failures. Client errors (4xx) count only when an administrator lists them.
  • The breaker complements fallback and retry: fallback handles one failed request, the breaker handles a failing provider.
  • The status API lists only providers whose breaker is open or half-open.

See also

  • Circuit breaker — thresholds, cooldown, counted failures, Myra-fleet exceptions and the status API.
  • Gateways — where the breaker is enabled.