In what situations would you use a Circuit Breaker in a microservices architecture?

A Circuit Breaker is used whenever a service depends on another component whose failure could otherwise cascade and destabilize the entire system, particularly when that dependency is prone to slowness or intermittent unavailability.

Key Points

Example

A Product Page calling an external Recommendation API is a prime candidate for a circuit breaker: if that third-party API becomes slow, the breaker trips and the page falls back to showing generic "popular products" instead of hanging or crashing the whole page load.

// Wrap calls to a dependency you don't control, such as a third-party API
@CircuitBreaker(name = "partnerRecommendations", fallbackMethod = "fallback")
public List<Product> recommendations(String productId) {
    return partnerApi.similarTo(productId);
}

private List<Product> fallback(String productId, CallNotPermittedException ex) {
    return bestSellers.top(8);           // circuit OPEN: answer instantly
}

private List<Product> fallback(String productId, Exception ex) {
    return bestSellers.top(8);           // the call itself failed
}

// The breaker's state can be watched in /actuator/circuitbreakers
// and as metrics (resilience4j_circuitbreaker_state) in Grafana.

Interview Tip

A concise interview answer is

I'd add a circuit breaker anywhere a synchronous call to another service could hang or fail unpredictably and risk cascading up to the caller — especially calls to external APIs I don't control. It lets the system fail fast with a fallback instead of tying up resources waiting on a dependency that's clearly struggling.

Last updated: 1 November 2026

Previous question: How does the Circuit Breaker pattern differ from the Retry pattern?

Next question: What is the purpose of the Service Discovery pattern in microservices?

More Microservices Design Patterns interview questions

All Microservices Design Patterns questions