Skip to main content

Configure a Circuit Breaker

Stop sending traffic to a service that is overwhelmed, by capping what the gateway sends it at the same time.

How it works​

A backend that slows down makes requests pile up in front of it, which slows it further. A circuit breaker caps how many connections and requests the gateway keeps open to the backend; beyond the cap it answers 503 at once, which lets the backend recover and lets callers fail fast.

Size the caps from normal traffic

Set them above the peak you observe in the gateway metrics, not at the default: too low a cap rejects healthy traffic.

Every parameter and its default: reference.

Use cases​

When a service slows down under load and makes things worse by receiving more.

Prerequisites​

Procedure​

  1. In API Manager, go to API Instances and open the API. To cover everything published on a gateway instead, open the gateway.
  2. Open its Backend traffic policies and add the rule circuit breaker.
  3. Lower the caps that fit your service: connections, waiting requests, parallel requests, parallel retries.
  4. Deploy.

Parameters​

FieldWhat it isDefault
Max ConnectionsThe most connections open to the service at the same time.1024
Max Pending RequestsThe most requests waiting for a free connection.1024
Max Parallel RequestsThe most requests being handled at the same time.1024
Max Parallel RetriesThe most retries running at the same time.1024

Behavior and limits​

  • A request beyond a cap is refused at once with 503, instead of waiting.
  • The defaults are high: measure what your service handles before lowering them.

See also​