CLOUD CONCEPT

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 Concepts Hub →

What is 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.

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.

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.

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.

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.

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.

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.

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.

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 image 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.

Open AWS Step Functions →
AWS Lambda image 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.

Open AWS Lambda →
Amazon DynamoDB image 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.

Open Amazon DynamoDB →
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.

Open Amazon Bedrock →
Amazon CloudWatch image 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.

Open Amazon CloudWatch →