Circuit breaker pattern
Concept
A resilience design pattern in which an application stops repeatedly calling a dependency that is already failing, preventing one problem from spreading through the rest of the workload.
Также обсуждаются
В выпуске на тему Circuit breaker pattern обсуждаются также: Child flows (Power Automate), Dead-lettering, Retry pattern, Idempotency, Trigger (Power Automate) и Power Automate.
Description
The circuit breaker pattern is a resilience design pattern in which an application stops repeatedly calling a dependency that is already failing. Its purpose is to keep one problem from spreading through the rest of the workload. Microsoft's Azure Architecture Center describes it as a way to temporarily block access to a remote service or resource once failures reach a threshold, so the application does not keep repeating an operation that is likely to fail.
The pattern works through a proxy, the breaker, that tracks recent failures and decides whether a call goes through or immediately raises an exception. This protects the calling application as well as the struggling service. Calls that are blocked would otherwise tie up memory, threads and database connections, which is how a single failing dependency can turn into a cascading failure. Blocking the calls gives the dependency time to recover.
The proxy behaves as a state machine with three states. In the Closed state, requests pass through normally and failures are counted over time. Once the failure count exceeds the threshold, the breaker switches to Open. In the Open state, requests fail at once without reaching the dependency, and a timeout timer runs. When the timer expires, the breaker moves to Half-Open, where a limited number of requests are allowed through as a test. If enough consecutive requests succeed, the breaker returns to Closed; if a request fails, it goes back to Open.
The circuit breaker is often compared with the Retry pattern. Retry assumes that a later attempt may succeed, while the circuit breaker assumes that continued attempts are likely to fail and should be stopped for a while. The Azure Architecture Center notes that the two can be combined, for example by retrying transient faults while the breaker prevents sustained hammering of a dependency that is clearly down.
The documentation also lists pitfalls to plan for. Timeouts that are too long, or an Open phase that lasts too long, can leave callers waiting or keep a recovered service blocked. Oscillation between states can occur when thresholds and timers are poorly tuned. A single shared breaker can also block healthy parts of a system if it covers more than the failing dependency. The pattern is not suited to local, in-memory resources, and it is not a replacement for business-logic exception handling.
In the Microsoft automation context, the episode "Build Enterprise Automation with Azure Logic Apps" lists the circuit breaker pattern among its recommended practices for workflows. It advises temporarily disabling actions after repeated failures so that external systems can recover. The episode places this alongside other error-handling measures: scope actions, retry policies and 'Run After' settings. It also recommends monitoring workflows with Azure Monitor and Application Insights, and setting alerts. Together these practices are presented as a way to keep workflow automation running smoothly as a business grows.
In practice, the decision to use the pattern centers on calls to remote or external systems whose failures are likely to last longer than a moment. Teams choose a failure threshold, an Open-state timeout and a rule for how many trial requests Half-Open allows, then monitor the breaker's state changes to see how the dependency behaves.
Overview compiled with AI from M365.FM episodes and the facts on this page. You can improve it with the edit button below.
| Type | Concept |
|---|
Community wiki
Short info above, community knowledge below: add practical tips, examples or corrections. New contributions are reviewed first; trusted members publish directly.
Experts and companies for this topic
Nobody has listed this topic yet. Add it to your profile.
Maintained by Mirko Peters (Microsoft MVP) · Last updated: