Circuit Breaker
Limits requests to unstable backends when failures exceed a threshold.
Use the Circuit Breaker policy to protect unstable backends by limiting traffic when failures reach a defined threshold. This helps the system fail fast and recover safely.
For more information on the policy parameter descriptions, see DataPower Nano Gateway documentation.
Example of a Circuit Breaker policy in code view.
kind: EnforceCircuitBreaker
apiVersion: api.ibm.com/v1
metadata:
name: ibm_cloud_login
version: 1
namespace: sample
spec:
preventHalfOpen: true #optional(default false) -> if set to false, while in the recover duration, once you get halfway through it, allow 50% of the traffic (1 in 2 requests can get in the execute)
recoveryDuration : 60 #optional(default 10s) -> min:1s, max:1day(in seconds)
breakConditions:
# (1/3) reported Failures
reportedFailures:
failureCount: 3 #Max failures reported before breaking the circuit.
failureDuration: 5 #Rolling window of seconds to monitor the count.
# # (2/3) reported Failures and Concurrency
# reportedFaluresAndConcurrency:
# failureCount: 3 #Max failures reported before breaking the circuit.
# failureDuration: 5 #Rolling window of seconds to monitor the count.
# maxConcurrentRequests : 15 #Max concurrent requests before breaking the circuit
# # (3/3) Concurrency
# concurrency:
# maxConcurrentRequests : 15 #Max concurrent requests before breaking the circuit.
execute:
- $ref : "sample:invoke_backend_1"
fallbackExecute : #less expensive than the execute, usually youd want to craft a custom error message here
- $ref : "sample:throw-503"