During peak hours, a downstream service provider may experience a performance bottleneck that even affects your business. In this case, you can use the service degradation feature to degrade some service consumers. Unimportant service consumers do not call the services provided by the provider. Instead, degraded responses are directly returned. Valuable resources of the downstream service provider are reserved for key service consumers. This way, the overall service stability is improved.
Background information
Existing open source circuit breakers, such as Sentinel and Hystrix, break the circuits for unstable calls to services with weak dependencies. This protects against overall system failures caused by unstable calls. Circuit breaking is a self-protective feature that is configured on service consumers in most cases.
The service degradation feature can be enabled regardless of whether a service call is normal. This feature protects service providers and ensures that resources are preferentially allocated to key service consumers.
The following example shows how to use service degradation in Dubbo applications.
- Service degradation rules are not configured.
By default, Consumers 1, 2, and 3 call instances of CartService by using getProviderIp, viewCart, and addItemToCart.
The following figure shows the call relationship when service degradation rules are not configured.
- Service degradation rules are configured.
A degradation rule is configured to use when Consumer 1 calls an instance of CartService by using getProviderIp. When you configure the service degradation rule, you select Return Custom Json Data from the Degradation Policy drop-down list and select All Requests for Effective Policy. After this rule is configured, if Consumer 1 wants to call an instance of CartService by using getProviderIp, Consumer 1 triggers a local service degradation based on the configured rule.
The following figure shows the call relationship after a service degradation rule is configured.
Limits
The service degradation feature is supported only in applications that are developed based on Dubbo 2.7.7 or later.