Circuit Breaker Plug-in
Overview
ROMA Connect uses circuit breakers to protect the system when performance issues occur on backend services. When the backend service of an API times out for N consecutive times or the latency is long, the circuit breaker downgrade mechanism is triggered to return a error to the API caller or forward the request to the specified backend. After the backend service recovers, the circuit breaker closes and the request becomes normal.
Parameter Description
|
Parameter |
Description |
|---|---|
|
Trigger Configuration |
|
|
Circuit Breaker Type |
Specify a circuit breaker type.
|
|
Conditions |
This parameter is mandatory only when Circuit Breaker Type is set to Condition downgrade. It specifies the latency threshold for the backend service to respond. |
|
Time Window |
Configure the time window for circuit breaker triggering. Use this parameter together with Threshold. Once the number of times when conditions are met within the time window exceeds the threshold, the circuit breaker is triggered. |
|
Threshold |
Configure the threshold for circuit breaker triggering. Use this parameter together with Time Window. Once the number of times when conditions are met within the time window exceeds the threshold, the circuit breaker is triggered.
NOTE:
A circuit breaker plug-in is triggered by a single gateway component. If ROMA Connect has multiple gateway components, the triggering statistics of each gateway component are collected separately. For a gateway component, if the maximum times when conditions are met are exceeded within the time window, requests sent to the component trigger the circuit breaker. Other gateway components still forward requests normally. To view the number of gateway components, go to the Instance Information page of a ROMA Connect instance by clicking the instance name on the console and view the number of IP addresses in Connection Addresses. One IP address indicates one gateway component. |
|
Control Duration |
Specify the duration of the circuit breaker. The circuit breaker will be closed at the end of the duration. |
|
Backend Downgrade Policy |
Specify whether to enable the backend degradation policy.
|
|
Backend Policy Type |
This parameter is mandatory only when Backend Downgrade Policy is enabled. Set the backend policy type for forwarding requests. Passthrough: passes the requests to the original API backend service. Click Add Parameter to add request header parameters to the request forwarded to the backend service. |
|
Downgrade Parameter Settings |
Specify whether to enable downgrade configuration. When enabled, it allows you to customize circuit breaker rules that take precedence over other rules.
|
|
Define Parameters |
Define the parameters for rule matching.
|
|
Define Rule |
Define the matching conditions, downgrade trigger conditions, and downgrade policies of rules. For details about how to configure trigger conditions and backend service downgrade policies, see the default degradation policy configuration in the preceding description. Click Add Rule to add rules. The system matches rules from top to bottom. Adjust the rule priority by moving the rules up or down.
For example, enable Downgrade Parameter Settings and add rules rule01 and rule02 rules in sequence. Disable Trigger Configuration and enable Backend Downgrade Policy for rule01 and enable both parameters for rule02. The circuit breaker first checks whether the matching condition of rule01 is met. If yes, the circuit breaker opens based on the default trigger condition because no trigger condition is configured in rule01, and the backend downgrade policy in rule01 is executed. If no, rule02 is checked. |
Script Configuration Example
{
"breaker_condition": {
"breaker_type": "timeout",
"breaker_mode": "counter",
"unhealthy_threshold": 1,
"time_window": 1,
"open_breaker_time": 1
},
"downgrade_default": {
"type": "passthrough",
"passthrough_infos": [
{
"location": "header",
"name": "sourceip",
"origin": "SYSTEM",
"value": "$context.sourceIp"
},
{
"location": "header",
"name": "header1",
"origin": "CONSTANT",
"value": "thisisheader1"
}
]
},
"downgrade_parameters": [
{
"name": "reqPath",
"type": "path",
"value": "path"
}
],
"downgrade_rules": [
{
"rule_name": "rule01",
"parameters": [
"reqPath"
],
"match_regex": "[\"reqPath\",\"==\",\"/test123\"]",
"breaker_condition": {
"breaker_type": "condition",
"breaker_mode": "counter",
"unhealthy_threshold": 0,
"time_window": 0,
"open_breaker_time": 0,
"unhealthy_condition": "[\"$context.backendResponseTime\",\">\",2000]"
}
"downgrade_backend": {
"type": "passthrough",
"passthrough_infos": [
{
"location": "header",
"name": "downgrade",
"origin": "CONSTANT",
"value": "true"
}
]
}
}
]
}
Last Article: HTTP Response Header Management Plug-in
Next Article: Configuring a Custom Authorizer
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.