ASP.NET Core Web API Interview Question #145
What is the circuit breaker pattern?
Error Handling, Logging, Caching, Rate Limiting, CORS & Reliability Senior Advanced
Quick Interview Answer
A circuit breaker temporarily stops calls to a dependency after repeated failures. This prevents every incoming request from continuing to wait on a dependency that is already known to be unhealthy.
Detailed Explanation
A circuit breaker temporarily stops calls to a dependency after repeated failures. This prevents every incoming request from continuing to wait on a dependency that is already known to be unhealthy.
After a defined period, the breaker can allow trial calls to determine whether the dependency has recovered. It is commonly combined with timeouts and carefully designed retries.
Code Example
// Closed: calls flow normally.
// Open: calls fail fast.
// Half-open: limited trial calls test recovery.
// Configure through the resilience strategy used
// by the application's HTTP client stack.