Failing downstream service + retries = amplified failure = cascade. Circuit breaker trips fast, saves you, probes for recovery. Universal microservice pattern.

CLOSEDrequests flowOPENfail fastHALF-OPENprobe requestsN failures / windowAfter open durationSuccess = close, Fail = openNormaldownstream healthyDegradedreturn fallback / cachedRecoveringtest waterfailurestimeout
Circuit breaker: CLOSED → OPEN on failures → HALF-OPEN probe → CLOSED or OPEN
Advertisement

CLOSED state

Normal. Requests flow. Failure counter increments on errors. Threshold reached → OPEN.

CLOSED state

Normal. Requests flow. Failure counter increments on errors. Threshold reached → OPEN.

Advertisement

OPEN state

Every request fails fast with CircuitOpenException. No downstream calls. Recover time = configured duration.

HALF-OPEN state

After OPEN duration, one probe request allowed. Success → close. Failure → open again (with longer duration).

Configuration

Failure threshold (5-10). Window (30s). Open duration (60s). Tune per downstream. Aggressive for critical, relaxed for optional.

Fallbacks

When circuit is OPEN, return cached value, degraded response, or 'service unavailable'. Never return random errors.

Three states + fail fast + probe + fallbacks. Every microservice call should have one.