Infrastructure · Primitives
CircuitBreaker
Fail-fast protection against cascading failures
Definition
Mechanism
State machine wrapper for fallible operations. Monitors failure rates of a target resource. States: (1) 'CLOSED': Requests pass normally. (2) 'OPEN': Requests fail immediately (Fail Fast) without invoking target. (3) 'HALF-OPEN': Limited trial requests allowed to test recovery. Transitions: 'CLOSED' -> 'OPEN' if failure count > threshold. 'OPEN' -> 'HALF-OPEN' after reset timeout. It wraps operations, switching to an open state on failure to prevent cascading overloads, while using Backoff and retry logic to schedule recovery probes.
Preconditions
- Failure threshold defined
- Target resource identified
Postconditions
- Internal state updated based on outcome
- Request processed OR Blocked
Invariants
Risks
Failure modes
Flapping
Threshold too sensitive causes circuit to oscillate between Open/Closed.
Zombie {{state}}
Circuit stuck 'OPEN' because reset logic failed to trigger or persists in failure.
False Positive
Transient network blips trip circuit, blocking healthy traffic.
Relationships
Builds on
Used by
References
Runtime anomaly signal
Default-deny policy for uncertain states
Mind
Classified re-attempt with backoff conditioned on failure type
Mind
Exercise the means of stopping an activity while it runs, so that it still works when needed
Composes with
Society
Progressive deployment with canary gating and recorded compensation
Reference
Parameters
failure_thresholdInteger, [1, 100]- Default: 5
half_open_limitInteger, [1, 10]- Max probes allowed in half-open state
reset_timeoutDuration, unspecified- Default: 60s
