Technical Glossary

Circuit Breaker

Definition: Resilience pattern that prevents cascading failures in distributed systems by stopping requests to a repeatedly failing service and allowing recovery time.

— Source: NERVICO, Product Development Consultancy

What is the Circuit Breaker pattern

The circuit breaker is a resilience pattern for distributed systems that works analogously to an electrical circuit breaker. When an external service fails repeatedly, the circuit breaker “opens” to stop requests to that service, preventing the failure from propagating to the rest of the system. After a configurable timeout, it allows test requests to verify whether the service has recovered.

This pattern was popularized by Michael Nygard in his book “Release It!” and is fundamental in microservices architectures.

How it works

The circuit breaker operates in three states. In the closed state, requests flow normally and the error rate is monitored. When errors exceed a configured threshold, the circuit breaker transitions to the open state: all requests are immediately rejected with a predefined error, without attempting to contact the remote service. After a waiting period, it enters the half-open state, where it allows a limited number of test requests. If these succeed, it closes again. If they fail, it opens again.

Libraries like Resilience4j (Java), Polly (.NET), or Hystrix implement this pattern with declarative configuration.

Why it matters

Without a circuit breaker, when a dependent service fails, requests pile up waiting for a response, consuming threads and connections. This progressively degrades the calling service, which in turn degrades others that depend on it, generating a cascade effect that can bring down the entire system.

Practical example

A checkout service calls the inventory service to verify stock. The inventory service starts responding with 30-second latency instead of 50 milliseconds. Without a circuit breaker, the checkout threads block waiting, and within minutes the checkout stops functioning. With a circuit breaker configured at a threshold of 5 consecutive failures, after detecting the problem the circuit opens and the checkout responds immediately with “stock verification temporarily unavailable,” keeping the rest of the purchase flow functional.

Need help with product development?

We help you accelerate your development with cutting-edge technology and best practices.