---
schema_version: "1"
id: 621f46a57e4d59e450f15e0a045666a2c00bd985b9821e4b9f385dd7fb2c19fe
title: Circuit Breaker Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/1.9/policies-outbound-circuit-breaker.md
canonical_url: https://docs.mulesoft.com/gateway/1.9/policies-outbound-circuit-breaker
source_site: docs.mulesoft.com
content_type: documentation
content_hash: adcf08c358b13de731d199ce0df6e9ab53141c7f64a751a67d4b3a581881915d
description: MuleSoft Documentation Site
release: "1.9"
latest: false
---
---
product: Omni Gateway
version: 1.9
---

# Circuit Breaker Policy

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Policy name</strong></p></td><td><div><div><p>Circuit Breaker</p></div></div></td></tr><tr><td><p><strong>Summary</strong></p></td><td><div><div><p>Prevents an upstream from receiving too many requests or connections</p></div></div></td></tr><tr><td><p><strong>Category</strong></p></td><td><div><div><p>Quality of Service</p></div></div></td></tr><tr><td><p><strong>First Flex Gateway version available</strong></p></td><td><div><div><p>v1.9.0</p></div></div></td></tr><tr><td rowspan="4"><p><strong>Returned Status Codes</strong></p></td><td><div><div><p>503 - Service Unavailable</p></div></div></td></tr></tbody></table>

## Summary

The Circuit Breaker policy prevents upstream services from receiving too many requests or
connections at a time. If the defined maximums are reached, Flex Gateway returns a
`503 - Service Unavailable` error.

For Managed Flex Gateways or Connected Mode, each API instance has its own independent limit when
requesting the same upstream, allowing each to use the full maximum. In Local Mode, the limits are
shared among different API instances, so they must all adhere to the same upstream maximum. For all
modes, maximums are not distributed across replicas; each Gateway can use the full maximum.

The Circuit Breaker policy is an extension of the Envoy upstream clusters circuit breaking feature.
To learn more about the Envoy’s circuit breaking, see
[Circuit Breaking](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/circuit_breaking.html)
in the Envoy documentation.

## Configuring Policy Parameters

### Flex Gateway Local Mode

In Local Mode, you apply the policy to your API via declarative configuration files. Refer to the
following policy definition and table of parameters:

apiVersion: gateway.mulesoft.com/v1alpha1 kind: PolicyBinding metadata: name: upstream-policy spec:
targetRef: Kind: Service name: upstream policyRef: name: circuit-breaker-flex config: thresholds:
maxConnections: <number> // OPTIONAL maxPendingRequests: <number> // OPTIONAL maxRequests: <number>
// OPTIONAL maxRetries: <number> // OPTIONAL maxConnectionPools: <number> // OPTIONAL

> [!NOTE] For Local Mode, the limits are not independent, so different API instances share the
> maximums for an upstream.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Required or Optional</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>maximumConnections</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of connections per API to an upstream.</p></div></div></td></tr><tr><td><div><div><p><code>maximumPendingRequests</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of queued requests while waiting for a connection.</p></div></div></td></tr><tr><td><div><div><p><code>maximumRequests</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of outstanding requests to an upstream.</p></div></div></td></tr><tr><td><div><div><p><code>maximumRetries</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of outstanding retries.</p></div></div></td></tr><tr><td><div><div><p><code>maximumConnectionPools</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of connection pools concurrently initiated to an upstream.</p></div></div></td></tr></tbody></table>

#### Resource Configuration Example

This example defines a policy that supports a maximum of one request at a time:

apiVersion: gateway.mulesoft.com/v1beta1 kind: Configuration metadata: name: circuit-breaker
namespace: test-ns spec: circuitBreaker: thresholds: maxConnections: 1 maxPendingRequests: 1
maxRequests: 1 maxRetries: 1 maxConnectionPools: 1

### Managed Flex Gateway and Flex Gateway Connected Mode

When you apply the policy to your API instance from the UI, the following parameters are displayed:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Required or Optional</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p>Maximum connections</p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of connections per API to an upstream.</p></div></div></td></tr><tr><td><div><div><p>Maximum pending requests</p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of queued requests while waiting for a connection.</p></div></div></td></tr><tr><td><div><div><p>Maximum requests</p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of outstanding requests to an upstream.</p></div></div></td></tr><tr><td><div><div><p>Maximum retries</p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of outstanding retries.</p></div></div></td></tr><tr><td><div><div><p>Maximum connection pools</p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Maximum number of connection pools concurrently initiated to an upstream.</p></div></div></td></tr></tbody></table>

> [!NOTE] For Managed Flex Gateways or Connected Mode, each API instance has its own independent
> limit when requesting the same upstream, allowing each to use the full maximum.
