# Circuit Breaker

A circuit breaker is a resilience pattern that temporarily blocks calls to a failing dependency and permits controlled probes before restoring normal traffic.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/circuit-breaker

> A circuit breaker tracks dependency failures and stops sending requests when a configured threshold is exceeded, preventing repeated failures from exhausting caller resources. It supports fast failure, graceful degradation, and controlled recovery, making it useful for foundation model invocations, agent tools, and other remote services.

Practice exams covering Circuit Breaker: [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Circuit Breaker

Circuit breakers isolate failing dependencies through measured trip conditions, fast rejection, controlled recovery, and observable state while complementing other resilience and safety controls.

1. **Stateful failure isolation**: Closed, open, and half-open states control whether requests reach a dependency. Scope each circuit to a meaningful failure boundary so one unhealthy endpoint does not disable unrelated operations.
2. **Evidence-based trip conditions**: Use classified failures, rolling measurement windows, and minimum request counts to decide when to open. Avoid treating every application error as evidence of dependency unavailability.
3. **Controlled recovery**: After a cooldown, allow only limited probe traffic and reopen the circuit if probes fail. Coordinate probe admission across distributed callers to prevent a recovery traffic surge.
4. **Fast failure and graceful degradation**: Reject calls quickly while the circuit is open, or route them to an explicitly approved fallback. Alternative models and Regions must satisfy compatibility, capacity, security, and compliance requirements.
5. **Complementary workflow safeguards**: Combine circuit breakers with deadlines, bounded retries, concurrency limits, and agent iteration or spending limits. Use authorization policies separately to enforce resource boundaries.
6. **Observable distributed state**: Record state transitions, blocked requests, fallback usage, and recovery outcomes. Shared implementations need concurrency-safe updates and an explicit policy for what happens when breaker state cannot be read.

## Cloud services for Circuit Breaker

Step Functions coordinates dependency calls, stopping conditions, and fallback paths, while Lambda can implement invocation wrappers and failure classification. DynamoDB provides shared breaker state and coordinated recovery probes across executions. Bedrock supplies model inference and, for supported models, cross-Region inference routing that can complement resilience policies. CloudWatch exposes failures, transitions, and degraded operation through metrics and logs. IAM limits the resources each path may access. Together, these services support resilient workflows, but the application must explicitly define trip thresholds, recovery rules, deadlines, and approved fallbacks.

- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/aws-step-functions)**: Implements breaker-aware workflow routing using Choice, Task, Wait, Retry, and Catch constructs together with explicit breaker logic and state. It can also enforce agent stopping conditions and route requests to fallback paths; Retry and Catch alone do not provide a shared circuit breaker.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Runs dependency wrappers that classify failures, consult or update breaker state, and enforce client request deadlines. Function execution timeouts bound execution duration but do not guarantee cancellation of remote work.
- **[Amazon DynamoDB](https://blowstack.com/tools/cloud-services-hub/amazon-dynamodb)**: Can hold shared breaker state, cooldown deadlines, and probe ownership across concurrent callers. Conditional writes support coordinated transitions; application logic should check cooldown timestamps rather than rely on asynchronous TTL deletion for recovery timing.
- **[Amazon Bedrock](https://blowstack.com/tools/cloud-services-hub/amazon-bedrock)**: Provides foundation model inference that applications can protect with circuit breakers. Supported cross-Region inference profiles offer managed routing across supported Regions, complementing application-level fallback and breaker policies without replacing them.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: Collects custom breaker metrics, application logs, and alarms for failure rates, state changes, blocked calls, and fallback use. These signals help tune thresholds and detect circuits that remain open or repeatedly oscillate between states.

## Circuit Breaker exam questions

Real practice exam questions on Circuit Breaker, with the correct answer and its explanation.

### Question 1 (DVA-C02)

**Question:**

An AWS Lambda function retrieves delivery estimates from a third-party API during checkout. When the API is unavailable, requests accumulate and consume Lambda concurrency. The application can return a cached estimate instead. A developer must make failures observed across concurrent invocations temporarily stop new calls to the API. The application must also detect recovery automatically without sending a burst of requests to the recovering API. Which implementation meets these requirements?

**Correct answer:** Store dependency health and a cooldown deadline in a shared data store. After the failure threshold is reached, return cached estimates without calling the API. After the cooldown, use an atomic conditional update to allow one recovery probe while other invocations continue using cached estimates. Resume normal calls on probe success and restart the cooldown on failure.

**Explanation:** This implements a shared circuit breaker. Shared state lets failures across invocations suspend dependency calls, and an atomically coordinated recovery probe prevents concurrent invocations from overwhelming the API when the cooldown expires.

### Question 2 (AIP-C01)

**Question:**

A company uses AWS Step Functions workflows to coordinate a generative AI support agent. Thousands of concurrent workflows invoke the same read-only external diagnostic tool. A shared health record tracks tool failures. When the failure threshold is exceeded, new calls are blocked for 60 seconds and workflows return a controlled tool-unavailable result.

Currently, all waiting workflows resume tool calls when the 60 seconds expire. This traffic surge repeatedly overwhelms the recovering tool. Some calls admitted before blocking began also complete successfully during the blocked period.

The company requires that only one recovery request be in flight across all workflows while the tool's health is being tested. Other workflows must continue returning tool-unavailable results. A successful recovery request must restore normal traffic, and a failed recovery request must start another blocked period. Results from requests admitted before blocking began must not restore traffic.

Which implementation meets these requirements?

**Correct answer:** Use conditional updates on the shared health record to grant one workflow exclusive recovery-probe ownership after the cooldown. Associate the probe with a health-state generation and ownership token. Allow only its matching result to restore traffic or start a new blocked period, and return tool-unavailable to other workflows while recovery is pending.

**Explanation:** An atomic conditional claim coordinates recovery across concurrent workflow executions. Generation and ownership checks prevent late results from older requests from changing the current state. A successful authorized probe restores traffic; a failed probe reopens the breaker for another cooldown. While the probe is pending, other workflows take the controlled fallback path.

## Practice Circuit Breaker in a full exam

Questions on Circuit Breaker in each practice exam, with every answer option and an explanation for each:

- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 8 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 1 question
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 1 question

## What is Circuit Breaker

A circuit breaker protects a caller from repeatedly invoking an unhealthy dependency. Without one, slow or failing model endpoints, databases, or external tools can consume connection pools, execution capacity, and request budgets. Retries can amplify the disruption by adding more traffic to an already overloaded service. A breaker interrupts that feedback loop and gives the dependency time to recover.

The usual states are closed, open, and half-open. When closed, requests pass through and their outcomes are measured. If failures exceed a configured threshold, the breaker opens and subsequent calls fail immediately or follow a fallback path. After a cooldown, the half-open state permits a limited number of probes. Successful probes close the breaker; failed probes reopen it. An open breaker blocks calls, despite the everyday association of an open gate with allowing passage.

Define failures according to the dependency and operation. Timeouts, connection failures, selected server errors, and sustained throttling can be appropriate signals. Invalid requests and authorization errors usually require correction rather than a recovery cooldown. A practical policy might open after a high failure percentage within a rolling window, provided a minimum number of requests has occurred. Thresholds must reflect normal latency and traffic volume; an overly sensitive policy can unnecessarily disable a healthy dependency.

In cloud workflows, orchestration can check breaker state before invoking a dependency and route failures to a handler that updates that state. AWS Step Functions can implement this control flow with Choice, Task, Wait, and error-handling constructs, but Retry and Catch alone are not a shared circuit breaker. Separate workflow executions need shared state if failures across callers should open the same circuit. A store such as Amazon DynamoDB can maintain the state, cooldown deadline, and probe ownership using conditional updates. Key the state by the intended failure boundary, such as model, endpoint, Region, and operation, rather than disabling unrelated dependencies.

For foundation model integration, opening a circuit around one endpoint can trigger an approved fallback model, a separately deployed regional endpoint, a cached response where appropriate, or an explicit temporary-unavailability response. Amazon Bedrock cross-Region inference uses supported inference profiles to route requests among supported Regions; it is not an application circuit breaker and does not make every model available everywhere. Cross-Region model deployments also require suitable capacity, configuration, and data access. Validate model compatibility, output quality, permissions, and data-residency requirements before enabling either fallback approach.

Agentic workflows need additional stopping conditions for maximum tool calls, elapsed time, token consumption, and repeated unsuccessful actions. A circuit breaker can isolate an unavailable tool, while explicit workflow checks stop unproductive agent loops. Lambda functions can enforce client request deadlines and have an execution timeout, but a timeout does not guarantee that a remote operation was canceled. Use idempotency for retried side-effecting actions. IAM policies independently restrict permitted resources and actions; neither a circuit breaker nor an agent stopping rule replaces authorization.

Combine the breaker with bounded retries, exponential backoff with jitter, request deadlines, and concurrency limits. Coordinate retry behavior across SDKs and workflow layers to avoid multiplying attempts. Trade-offs include shared-state overhead, inconsistent observations across callers, false trips, and delayed recovery during cooldown. Monitor state changes, rejected calls, probe results, latency, and fallback use. Test both outage and recovery behavior, including concurrent half-open probes and failure of the breaker-state store itself.

## Learn Circuit Breaker in lessons

5 short lessons on Circuit Breaker in 2 certification courses.

- SAP-C03: Bulkhead Pattern vs Circuit Breaker (Premium), https://app.blowstack.com/lessons/bulkhead-pattern-vs-circuit-breaker-sap-c03
- AIP-C01: Circuit Breaker: shared-state failure isolation (Premium), https://app.blowstack.com/lessons/circuit-breaker-shared-state-failure-isolation-aip-c01
- SAP-C03: Circuit Breaker: coordinated tripping and recovery (Premium), https://app.blowstack.com/lessons/circuit-breaker-coordinated-tripping-and-recovery-sap-c03
- SAP-C03: Circuit Breaker vs Exponential Backoff (Premium), https://app.blowstack.com/lessons/circuit-breaker-vs-exponential-backoff-sap-c03
- SAP-C03: Circuit Breaker vs Rate Limiting (Premium), https://app.blowstack.com/lessons/circuit-breaker-vs-rate-limiting-sap-c03
