During peak hours, a downstream service provider may run into a performance bottleneck that even affects the business. In this case, you can use the service degradation feature to degrade some service consumers. By using this feature, unimportant service consumers do not call the service. Instead, mocked responses are directly returned. Valuable resources of the downstream service provider are reserved for important service consumers. This way, the overall service stability is improved.
Existing open source circuit breakers such as Sentinel and Hystrix break the circuits for unstable calls to services with weak dependencies. The overall system failure that may be caused by local instability factors is prevented. Circuit breaking is a self-protective feature that is often configured on service consumers.
The service degradation feature can be enabled when a service call is abnormal or normal. This feature protects service providers and ensures that more limited resources are allocated to important service consumers.
The following example shows how to use the service degradation feature in Dubbo.
- Service degradation is not configured.
By default, Consumers 1, 2, and 3 call all request methods of the productservice service in CartService, including getProviderIp, viewCart and addItemToCart.
The following figure shows the call relationship when service degradation is not configured.
- Service degradation is configured.
You can configure Consumer 1 to be degraded when Consumer 1 attempts to call the /getIp path of the productservice service in ProductService. Select Return custom Json data from the App to be downgraded drop-down list. Select Effective for all requests for Effective strategy. These settings ensure that when Consumer 1 needs to call the getProviderIp of the CartService, Consumer 1 does not call CartService. Instead, Consumer 1 locally mocks the call based on the degradation rule.
The following figure shows the call relationship when service degradation is configured.
Create a service degradation rule
- Log on to the EDAS console.
- In the left-side navigation pane, choose .
- In the left-side navigation tree of Dubbo, click Service Degradation.
- On the Service Degradation page, select a region and a Namespaces. Then, click Create degrade rules.
- In the Create degrade rules panel, configure the parameters and click OK.
The following table describes the parameters.
Parameter Description Namespace Select the region and namespace to which the application belongs. Rule name Enter the name of the service degradation rule. The name can be a maximum of 64 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). Description Enter the description of the service degradation rule. Service Provider Application Select the application that can be called by other applications. Downgrade service consumer applications Select the application that you want to downgrade. Service Degradation Rule List Click Add service downgrade rules to create a service degradation rule. Frame type Select Dubbo. Service method Select the application that you select for the Service Provider Application parameter and select the interface that is used to call the application. Effective strategy Select the policy based on which the service degradation rule takes effect. Valid values: Effective for all requests and Effective for abnormal requests. App to be downgraded Select the policy for the service degradation rule. If the rule is triggered, the specified content is returned. Valid values: Return Null , Return Exception, and Return custom Json data. State Enable or disable the service degradation rule.
- On: The rule is enabled after it is created. This is the default value.
- Off: The rule is not enabled after it is created. To enable the rule, find the rule on the Service Authentication page and click Enable in the Operation column.