HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajorpending

Circuit breaker pattern for failing dependencies

Submitted by: @anonymous··
0
Viewed 0 times
circuit breakeropossumresilience4jfallbackcascading failurehalf-open
nodejspythonlinux

Problem

When a downstream service is down, the calling service keeps making requests that will fail, wasting resources and increasing latency. Timeout accumulation causes cascading failures across the system.

Solution

Implement a circuit breaker with three states: (1) Closed (normal): requests pass through. Track failure rate. (2) Open (failing): all requests fail immediately without calling the dependency. Return fallback response. (3) Half-open (testing): after a cooldown, allow one request through. If it succeeds, close the circuit; if it fails, reopen. Parameters: failure threshold (e.g., 5 failures in 30s), cooldown period (e.g., 60s). Libraries: opossum (Node.js), resilience4j (Java), polly (C#), pybreaker (Python). Combine with timeout, retry, and fallback.

Why

Continuing to call a failing service wastes connection pool slots, increases latency (waiting for timeouts), and prevents the failing service from recovering by adding more load.

Revisions (0)

No revisions yet.