Reliabilitybreakerpolly

Circuit breaker

Definition

A circuit breaker tracks failures of calls to a dependency and, past a threshold, opens to reject calls immediately; after a cool-down it lets trial calls through (half-open) and closes again if they succeed.

In practice

When a dependency is down or very slow, every call waits for a timeout and holds threads, connections and memory. A breaker turns those slow failures into instant ones, protects the caller from exhaustion and gives the dependency room to recover.

Thresholds need care: too sensitive and normal blips open the breaker, too lax and it never helps. An open breaker should trigger a fallback (cached data, a default, a clear error) rather than just an exception.

Example

If more than 50% of at least 20 calls to the recommendations service fail within 30 seconds, the breaker opens for 15 seconds and the page renders without recommendations.