Circuit Breaker
Problem
- The Orders service calls the Payments service.
- Traffic spikes. Payments starts taking 9 seconds instead of 1 second.
- Orders threads pile up waiting on Payments. Other services that use Orders for past-order history start failing too, even though they never touch Payments.
One struggling service starts taking down everything around it.
Solution
Circuit Breaker
- After a few failures, stop calling Payments for a short time.
- Return an error immediately instead of waiting.
- After the pause, let one trial call through.
- If it succeeds, close the breaker and allow calls again.
Payments gets time to recover, and Orders threads are free to serve everyone else while it does.
Fail fast, recover smart. That pause-and-retry sequence is the circuit breaker itself.
Analogy
Too many appliances run on one line, the wiring starts to overheat, and the breaker in your fuse box trips. The power cuts at once, and the house is saved from a fire.
Once the overload is fixed, you flip the breaker back on and power flows again.
The software pattern copies this exactly. It's called a circuit breaker for a reason.