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
  • 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.

    Service degradation rules are configured

Limits

The service degradation feature is supported only in applications that are developed based on Dubbo 2.7.7 or later.

Create a service degradation rule

  1. In the left-side navigation pane, choose Microservices Governance > Service Degradation.
  2. On the Service Degradation page, click Create Service Degradation Rule.
  3. In the Create Service Degradation Rule panel, configure the parameters and click OK.

    The following table describes the parameters.

    Parameter Description
    Rule Name Enter the name of the service degradation rule that you want to create. The name must be 1 to 64 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    Description Enter the description of the service degradation rule that you want to create.
    Service Provider Application Select the provider application.
    Degradation Consumer Application Select the consumer application that you want to downgrade from the drop-down list.
    Service Degradation Rules Click Add Service Degradation Rule to add a service degradation rule.
    Framework Type Select Dubbo.
    Service Path Select the consumer application and its interface.
    HTTP Request Method Select the request method for the consumer application.
    Effective Policy Select a policy about how to make the service degradation rule take effect based on your business requirements. Valid values: All Requests and Effective for Requests That Trigger Exceptions.
    Degradation Policy Select a policy for service degradation from the drop-down list based on your business requirements. Valid values: Return Null Value, An exception returned, Return Custom Json Data, and Customize Callback.
    Note If you select Customize Callback, the custom callback function is defined in client applications. The parameters and return values of the custom callback function must be the same as those of the original callback function. The class of the custom callback function must have the default constructor.
    Use Default Values Specifies whether to enable the service degradation rule.
    • If you turn on this switch, the rule is enabled after it is created. By default, this switch is turned on.
    • If you turn off this switch, the rule is not enabled after it is created. To enable the rule, find the rule on the Service Degradation page, and click Enable in the Actions column.

Result

After you create and enable the service degradation rule, check whether the rule takes effect based on your business requirements.

What to do next

After you create the service degradation rule, you can edit the rule. You can also disable or enable the rule based on the status of the rule. If you no longer require the rule, you can delete the rule.