When a service fails or is abnormal, it may trigger the circuit breaker to prevent other callers from waiting until a timeout error or fault occurs, thereby avoiding a cache avalanche. You can also perform the following operations to ensure that faults are controllable:
- When the monitoring result or service topology shows that a service has a long delay or a high error rate, perform service governance.
- Configure an automatic circuit breaker rule for an abnormal service. You can customize the trigger conditions, for example, when the number of requests within a certain period (such as 10s) reaches a threshold and the error rate or delay reaches a threshold.
When the conditions are met, the circuit breaker is triggered. You can also continuously test the service and configure the service to automatically recover from the circuit breaker according to the test result.
Ensure that the SOFABoot version is 3.3.3 or later. For more information about SOFABoot versions, see Release notes.
- Log on to the SOFAStack MS Platform console, choose Microservices > Service governance. The Service governance page appears.
- Click the Circut break tab, click New rule, and then define a circuit breaker rule.
- Source: the service, such as SOFARPC.
- Application: the app name. Generally, an app corresponds to multiple services.
- Service: the service for which you want to apply the circuit breaker rule. You can perform either of the following operations based on whether the service management component has updated the corresponding app and service:
- Updated: Select a service from the drop-down list that appears.
- Not updated: Select a service that has been configured for your app.
- Method: the name of the method for which you want to apply the circuit breaker rule. If you do not specify this parameter, the circuit breaker rule will apply to the entire service.
- Mode: Valid values include Intercept mode and Observer mode. When the circuit breaker is triggered, the following processing will be implemented:
- Intercept mode: Trigger a service failure.
- Observer mode: Record logs only.
- Supported protocol: Currently, only SOFARPC is supported.
- Click Submit.