circuit-breaker
Stops sending requests to a failing upstream for a while, answering 503 instead, then lets traffic back once it recovers.
| Phases | on_http_request |
| Terminating | No — the next action runs after it. |
| Cost | 10 Traffic Policy units per run · not on the Free plan |
Example
policy.yaml
on_http_request:
- actions:
- type: circuit-breaker
config:
error_threshold: 0.25
volume_threshold: 20
window_duration: 30s
tripped_duration: 1m
Start an agent endpoint with it: devgate http 8080 --traffic-policy-file policy.yaml, or paste it into a
reserved or cloud endpoint’s Traffic Policy tab in the dashboard.
Configuration
| Field | Type | Description |
|---|---|---|
error_threshold | number | The share of failed requests, 0 to 1, that trips the breaker. Default: 0.5. |
volume_threshold | integer | How many requests the window must hold before the error share counts. Default: 10. |
window_duration | duration | The rolling window requests are counted in, 1s to 2m. Default: 10s. |
tripped_duration | duration | How long requests are refused once it trips, 1s to 2m. Default: 10s. |
num_buckets | integer | How the window is divided; fixed at 10. Default: 10. |
enforce | boolean | When false, the breaker never trips. Default: true. |
Behaviour
- Each request the breaker lets through is counted when it finishes: a 5xx answer, or a connection that ended without one, is an error.
- Once the window holds volume_threshold requests and error_threshold of them failed, the breaker trips: for tripped_duration requests get 503 with a Retry-After header and never reach your service.
- Then one request is let through to test the upstream: if it succeeds the breaker closes and counting starts over; if it fails, the breaker trips again.
- Counts are kept per endpoint and per action, at the edge.
- With error_threshold: 0 any traffic trips it — a way to let through one request per window.
Other actions
add-headers remove-headers compress-response basic-auth oauth openid-connect jwt-validation custom-response deny redirect url-rewrite restrict-ips rate-limit verify-webhook http-request set-vars log close-connection forward-internal