A checkout service asks a shipping-rate provider for a quote. The provider slows down. Each checkout waits, workers fill up, and the company’s own site begins to look broken even for customers who never needed that particular carrier. Trying the same call harder is not a recovery plan.
A software circuit breaker is a control around calls to a dependency that can temporarily stop sending requests when recent failures meet a defined condition. It can return a fallback or an error sooner, giving the caller and dependency room to recover. The Microsoft architecture guide describes the familiar closed, open and half-open states. A breaker is not the same as a timeout or a retry, and its behavior depends on its implementation and configuration.
The electrical metaphor is useful right up to the point where someone assumes a breaker fixes the wiring. It does not make the shipping provider healthy. It changes what your system does while the call is likely to fail, and it makes the resulting trade visible: faster failure can preserve capacity, but customers may see fewer available choices.
Three states, one decision about the next call
When a breaker is closed, calls are allowed through. The breaker observes selected outcomes and updates its failure measurements. A timeout, a refused connection or a provider error may count, but not every implementation counts the same events. A valid “address not found” response might be a customer-input problem rather than evidence that the shipping provider is unhealthy. Counting every unsuccessful business result as a dependency failure can open the breaker for the wrong reason.
When the configured threshold is reached, the breaker opens. During the open period, the protected call is rejected or short-circuited without contacting the dependency. The calling application must still decide what to do with that result. It might show another carrier, offer a previously approved quote within its permitted age, or explain that the rate is unavailable. A fallback is a product decision, not a magic value the breaker supplies.
After a configured interval, a half-open state can allow a limited trial of calls. If the trial meets the implementation’s success condition, the breaker can close; if it fails, the breaker can reopen. The limited trial matters because a service that has just restarted may not withstand every waiting client arriving at once. Different libraries use different thresholds and transitions, so read the behavior of the one actually deployed rather than treating the diagram as a universal contract.
A worked incident with no invented certainty
Suppose a company has two independent rate providers and places a separate breaker around each. Its first provider normally responds within an agreed operational window. During a hypothetical five-minute incident, a burst of calls to that provider times out. After the configured failure condition is met, the first breaker opens and new requests use a clearly labeled alternative or receive an unavailable message. The second provider’s breaker remains closed if its own calls are healthy.
That separation limits the effect of one provider’s failure. It does not guarantee a successful checkout: the second provider might lack coverage, the customer’s address could be invalid, or the application could have another problem. It also does not mean the original requests were free. Calls already in flight consume resources until their own deadlines or cancellations take effect. The breaker affects subsequent decisions; it does not retroactively cancel every operation.
If the team instead used one breaker for all shipping providers, failures from one could suppress the healthy one. The right boundary could be a provider, a specific endpoint, a region or a customer partition. Too broad and unrelated traffic shares a failure. Too narrow and the system has so many independent counters that a real shared outage is difficult to identify. Choose a boundary that matches a plausible dependency failure and can be observed.
Timeouts and retries still have jobs
A timeout bounds how long a caller waits for an attempt. A retry makes another attempt under selected conditions. A circuit breaker decides whether a call should be attempted at all given recent observations. They can be combined, but their settings interact. A very long timeout means the system may hold many requests before enough failures are observed to open. An aggressive retry policy can multiply traffic to a struggling dependency before the breaker reacts.
Consider an operation that times out after two seconds and is retried twice. One user action can create up to three attempts if all are actually made; additional layers with their own retries can multiply attempts further. The user’s total wait also includes any delays between attempts and work outside those calls. This is a simple upper-count illustration, not a recommendation for two seconds or two retries. Document which layer owns retries, which failures qualify, and the end-to-end deadline.
Retries are especially sensitive for writes. If a payment or reservation request times out, the caller may not know whether the provider completed it. A circuit breaker cannot answer that question. A retry without a provider-supported idempotency mechanism can create a duplicate effect. Preserve the operation identifier, use the provider’s documented recovery process and reconcile the actual state before treating a timeout as “nothing happened.” Our idempotency guide explains that separate concern.
What belongs in the failure count?
Start with the dependency’s contract and the behavior the business can tolerate. Connection failures, timeouts and some server errors may be useful signals of an unhealthy dependency. A rejected credential could indicate a configuration incident that needs urgent repair, but blindly treating it as a short transient outage may keep a bad credential in circulation. A rate-limit response may call for a different response, such as respecting the provider’s documented delay and reducing demand; its meaning depends on the provider.
The denominator matters too. Imagine a rule that opens after five failures in a window. Five failures out of six calls tell a different operational story from five out of 50,000. Conversely, a percentage threshold with no minimum volume can swing wildly when only two calls were made. Some libraries support both a sample requirement and a failure rate; others do not. Select the rule based on traffic and consequences, then test it with low-volume periods as well as bursts.
Do not hide the distinction between a failed dependency call and a deliberately short-circuited call. If both become one generic “error” metric, the team cannot tell whether the provider is still failing or the breaker is intentionally refusing new calls. Record state changes, rejected calls, actual attempts, latency and the selected fallback without logging secrets or sensitive payloads. A short-circuited request is evidence of the local policy in effect, not a fresh test of the provider.
The fallback can become the incident
A fallback that shows yesterday’s inventory as available may create more work than a clear unavailable message. A cached quote may be useful only within a defined validity period and only if its terms still apply. A queue can preserve a request for later processing, but it creates its own questions: when does the request expire, can it be safely repeated, and what does the customer see while it waits? None of those answers follows from adding a circuit-breaker library.
For a read-only product recommendation, a generic result might be acceptable. For a money movement or a legal eligibility decision, a fabricated “success” is not. Decide which degraded behavior is authorized for each operation and label uncertain results honestly. If a fallback has its own dependency, protect and monitor it too; a supposedly independent backup that uses the same failing database is not much of a backup.
Half-open tests deserve the same care. A harmless read may show that a server responds but not that its critical write path works. A real write can create side effects. Use a documented health or verification operation where available, or design a safe, representative check with the provider. A single successful response is useful evidence, not proof that every region and operation has recovered.
Make recovery legible to the people on call
Before enabling a breaker, run a controlled test in an appropriate environment. Simulate a slow dependency, verify the timeout, observe the transition to open and confirm the exact response shown to a caller. Then restore the dependency and watch a limited half-open trial. Test the fallback with missing, stale and invalid inputs, and check what happens to work already in flight. A passing unit test of a counter does not establish that the customer-facing flow behaves acceptably.
Decide who can change a threshold or force a state, what evidence they need and how a change is recorded. An operator who opens the breaker during a known provider incident should also know how it will be restored. An always-open breaker can look pleasantly fast in a latency chart while quietly denying the feature. An always-closed breaker can look healthy until the next surge. Review both the dependency metrics and the actual customer outcomes.
The goal is not to make an error disappear from the dashboard. It is to prevent one unreliable call from consuming the capacity needed for everything else, while keeping a truthful account of what the customer did and did not receive.
Explore Infinite Upside
For Vijay Sheth’s personal accounts, read Infinite Upside: Building Wealth With Room to Live, published by Sheth Capital, Inc.
Explore a related guide
What Does an HTTP 429 Response Mean?