What is the Circuit Breaker pattern?

The Circuit Breaker pattern protects a system from repeated calls to a failing service by temporarily stopping those calls and giving the failing service time to recover.

Diagram: circuit breaker states CLOSED, OPEN and HALF-OPEN
circuit breaker states CLOSED, OPEN and HALF-OPEN

Key Points

Example

If a downstream Recommendations service starts timing out, a circuit breaker around calls to it opens after, say, five consecutive failures, so the caller immediately falls back to a default recommendation list instead of waiting on every request for a timeout.

CircuitBreakerConfig config = CircuitBreakerConfig.custom()
    .failureRateThreshold(50)
    .waitDurationInOpenState(Duration.ofSeconds(10))
    .slidingWindowSize(20)
    .build();

CircuitBreaker breaker = CircuitBreaker.of("recommendations", config);

Supplier<List<Item>> decorated = CircuitBreaker
    .decorateSupplier(breaker, recommendationsClient::fetch);

Interview Tip

A concise interview answer is

A circuit breaker monitors failures on calls to a dependency and, once they cross a threshold, opens and stops sending further requests, failing fast instead of piling up timeouts. After a cooldown it lets a few test requests through to check recovery before fully closing again. It's a key resilience pattern I'd implement with something like Resilience4j.

Last updated: 11 November 2026

Previous question: What patterns are used to handle failures in microservices?

Next question: How does the Bulkhead pattern help in improving system resilience?

More Microservices - Level I interview questions

All Microservices - Level I questions