midreliability
A pattern that prevents cascading failures by breaking the chain of calls.
A Circuit Breaker wraps calls to an external service and tracks failures. When the error threshold is exceeded, it trips open (OPEN), blocking requests. It periodically attempts to restore the connection (HALF-OPEN).
States:
▸CLOSED — normal operation, requests pass through
▸OPEN — circuit is broken, fail fast
▸HALF-OPEN — test request to check recovery
When yes
Calls to external services, databases, slow dependencies with high timeouts
When no
Internal fast synchronous calls, idempotent operations without side effects
Interview tip
Mention Resilience4j (Java), Polly (.NET), hystrix (legacy) as implementations
Alt:Retry + exponential backoffBulkheadTimeout