All Products
Search
Document Center

Microservices Engine:Configure a circuit breaking rule

Last Updated:Jul 09, 2025

In Microservices Engine (MSE), you can use circuit breaking rules to monitor the response time of requests or ratio of abnormal requests for an application or a downstream application on which the application depends. If the specified threshold is reached, MSE immediately lowers the priority of the dependent downstream application. The system does not call the abnormal downstream application within the specified period of time. This ensures stability and high availability of your application. After the specified period elapses, the system resumes calls to the dependent downstream application. This topic describes how to create a circuit breaking rule and provides sample rules for common scenarios.

Prerequisites

Background information

In addition to traffic control, circuit breaking for unstable methods or downstream dependencies in a call trace is also a key measure for traffic protection. Due to the complexity of call relationships, if an error occurs in any part of the call trace, the request fails. This can even amplify the instability and cause the entire trace to become unavailable. When a method in the call trace becomes unstable (for example, when the method times out or its ratio of abnormal requests increases), the circuit breaking feature restricts calls to that method. This allows the request to fail fast and prevents the error from affecting the entire trace.

In most cases, circuit breaking rules are applied to scenarios in which you need to lower the priority of a weakly dependent application.

For more information about sample circuit breaking rules, see the Scenario 1: Create a circuit breaking rule for slow calls and Scenario 2: Create a circuit breaking rule for abnormal requests sections of this topic.

Feature access

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, find and click an application that you want to manage. On the details page of the application, create a circuit breaking rule by using one of the following methods:

    • In the left-side navigation pane, click API Details. On the page that appears, click the Client tab. Select an interface and click the Circuit Breaking tab. On the Circuit Breaking tab, click Added fusing rule.

    • In the left-side navigation pane, click Traffic management. Click the Flow protection tab, click Fuse rule, and then click Added fusing rule.

  4. In the Add Circuit Breaking Rule dialog box, configure the rule parameters and click New.

For more information about the rule parameters, see the Parameters section of this topic.

Rule details

The following table describes the parameters in the Add Circuit Breaking Rule dialog box.

Parameter

Description

Interface name

Application resources to which the rule applies.

Statistical window duration

The length of the time window. The valid range is from 1 second to 120 minutes.

Minimum number of requests

The minimum number of requests to trigger circuit breaking. If the number of requests in the current time window is less than the value of this parameter, circuit breaking is not triggered even if the circuit breaking rule is met.

Threshold Type

The threshold type. Valid values: Slow call ratio (%) and Abnormal proportion (%).

  • If you set this parameter to Slow call ratio, you must set the Slow call RT parameter, which specifies a threshold for the response time of requests. If the response time of a request exceeds the value of the Slow call RT parameter, the request is counted as a slow call.

    You must also set the Circuit Breaking Ratio Threshold parameter, which specifies a percentage threshold that triggers circuit breaking for slow calls. After the circuit breaking rule is enabled, if the number of requests in the specified time window is greater than the value of the Minimum number of requests parameter and the percentage of slow calls is greater than the value of the Circuit Breaking Ratio Threshold parameter, requests are automatically blocked within the circuit breaking period that is specified by the Circuit Breaking Duration (s) parameter. After the circuit breaking period elapses, the circuit breaker enters the detection and recovery state. If the response time of the next request is less than the value of the Slow call RT parameter, circuit breaking ends. If the response time of the next request is greater than the value of the Slow call RT parameter, circuit breaking is triggered again.

  • If you set this parameter to Abnormal proportion, you must set the Circuit Breaking Ratio Threshold parameter, which specifies a percentage threshold that triggers circuit breaking for abnormal requests.

    After the circuit breaking rule is enabled, if the number of requests in the specified time window is greater than the minimum number of requests and the percentage of abnormal requests is greater than the value of the Circuit Breaking Ratio Threshold parameter, requests are automatically blocked within the circuit breaking period that is specified by the Circuit Breaking Duration (s) parameter.

Circuit Breaking Duration (s)

The period in which circuit breaking is implemented. If circuit breaking is implemented on the resources, all requests quickly fail in the configured duration.

Circuit Breaking Policy

Recovery policy for the circuit breaker's recovery phase (half-open state).

  • Single detection recovery: After the circuit breaking period elapses, the circuit breaker detects the next request. If the request is not a slow call or an abnormal request, circuit breaking ends. Otherwise, circuit breaking is triggered again.

  • Progressive recovery: If you select this option, you must set the Number of recovery phases and Minimum number of passes per step parameters.

    • After the circuit breaking period elapses, the circuit breaker performs progressive recovery based on the specified number of recovery stages. If the number of requests in a stage reaches the value of the Minimum number of passes per step parameter, a check is triggered. If the number of checked requests does not exceed the configured threshold, the percentage of requests that are allowed to pass is gradually increased until all the requests are allowed to pass. If the number of checked requests exceeds the configured threshold in a stage, circuit breaking is triggered again.

    • The request percentage is calculated based on the following formula: Request percentage (T) = 100/Number of recovery stages (N). The request percentage in the first stage is T and the request percentage in the second stage is 2T. The calculation ends until the request percentage is equal to 100%.

    • For example, if the number of recovery stages is 3 and the minimum number of requests that are allowed to pass in each stage is 5, requests are distributed in the three stages based on the percentages of 33%, 67%, and 100%. If the number of requests in each stage is greater than or equal to 5, a check is triggered. If the number of requests in each stage is less than 5, the system enters the next recovery stage until all the requests are allowed to pass.

Scenario 1: Create a circuit breaking rule for slow calls

For example, if you call a third-party service and the response time is long, the calls to the current interface are affected. To resolve this issue, you can perform circuit breaking on the slow calls.

In the Add Circuit Breaking Rule dialog box, configure the parameters that are described in the following table.

Parameter

Example

Description

Interface name

test

Interface name.

Statistical window duration

1

Set this parameter to 1. Unit: seconds.

Minimum number of requests

10

The minimum number of requests to trigger the circuit breaker is 10.

Threshold Type

Slow call ratio

Set this parameter to Slow call ratio (%).

Slow call RT

1000

Set this parameter to 1000. Unit: milliseconds. If the response time of a request exceeds 1,000 milliseconds, the request is counted as a slow call.

Circuit Breaking Ratio Threshold

80%

Set this parameter to 80. Unit: %. If the percentage of slow calls reaches 80%, circuit breaking is triggered.

Circuit Breaking Duration (s)

10

Set this parameter to 10 seconds.

Circuit Breaking Policy

Single detection recovery

After the circuit breaking period elapses, the circuit breaker detects the next request. If the request is not a slow call or an abnormal request, circuit breaking ends. Otherwise, circuit breaking is triggered again.

After the circuit breaking rule is enabled, if the number of requests is greater than 10 and the percentage of slow calls is greater than 80% within one second, all the requests fail within the next 10 seconds. After 10 seconds, the circuit breaker detects the next request. If the response time of the next request is less than 1,000 milliseconds, circuit breaking ends. Otherwise, circuit breaking is triggered again.

Scenario 2: Create a circuit breaking rule for abnormal requests

For example, when the content of a third-party service is displayed, abnormal requests occur in the system. If the ratio of abnormal requests is high, you can perform circuit breaking on the abnormal requests to ensure a better user experience.

In the Add Circuit Breaking Rule dialog box, configure the parameters that are described in the following table.

Parameter

Example

Description

Interface name

test

API name.

Statistical window duration

1

The statistics collection period is 1 second.

Minimum number of requests

10

The minimum number of requests to trigger the circuit breaker is 10.

Threshold Type

Abnormal proportion

Set this parameter to Abnormal proportion (%).

Circuit Breaking Ratio Threshold

80%

Set this parameter to 80. Unit: %. If the percentage of abnormal requests reaches 80%, circuit breaking is triggered.

Circuit Breaking Duration (s)

10

Set this parameter to 10 seconds.

Circuit Breaking Policy

Single detection recovery

After the circuit breaking period elapses, the circuit breaker detects the next request. If the request is not a slow call or an abnormal request, circuit breaking ends. Otherwise, circuit breaking is triggered again.

After the circuit breaking rule is enabled, if the number of requests is greater than 10 and the percentage of abnormal requests is greater than 80% within one second, all the requests fail within the next 10 seconds. After 10 seconds, the circuit breaker detects the next request. If the next request is normal, circuit breaking ends. Otherwise, circuit breaking is triggered again.