All Products
Search
Document Center

Microservices Engine:Configure a retry policy

Last Updated:Apr 29, 2024

Cloud-native gateways allow you to configure retry policies at the route level. After you configure a retry policy, cloud-native gateways can automatically retry a failed request based on the retry policy. In a retry policy, you can specify retry conditions, such as failed connections, unavailable backend services, or a response with a specified HTTP status code.

Retry conditions

If the backend service returns a 5xx status code, your cloud-native gateway automatically retries the failed request for specified times.

  • Retry conditions for HTTP requests:

    • 5xx: The backend service returns a 5xx status code, or a disconnection, reset, or read timeout event occurs.

      Note

      The 5xx condition includes the connect-failure and refused-stream conditions.

    • reset: A disconnection, reset, or read timeout event occurs.

    • connect-failure: The request failed due to a disconnection.

    • refused-stream: The backend server returns the REFUSED_STREAM status code.

    • retriable-status-codes: The backend server returns one of the specified status codes.

      Note

      You can specify the status codes only if you select retriable-status-codes as a retry condition.

  • Retry conditions for gRPC requests:

    • cancelled: The CANCELLED status code is contained in the header of the response from the backend gRPC service.

    • deadline-exceeded: The DEADLINE_EXCEEDED status code is contained in the header of the response from the backend gRPC service.

    • internal: The INTERNAL status code is contained in the header of the response from the backend gRPC service.

    • resource-exhausted: The RESOURCE_EXHAUSTED status code is contained in the header of the response from the backend gRPC service.

    • unavailable: The UNAVAILABLE status code is contained in the header of the response from the backend gRPC service.

Configure a retry policy

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

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click Routes, and click the Routes tab.

  4. On the Routes tab, find the routing rule that you want to modify, and click Policies in the Actions column.

  5. On the Policies tab, click Retry.

  6. On the Retry tab, configure the parameters and click OK.

    Parameter

    Description

    Retry Times

    The maximum number of retries for a failed request. You can set this parameter to an integer ranging from 0 to 10. We recommend that you set this parameter to 0, 1, or 2.

    Note

    If you set this parameter to 0, failed requests are not retried.

    Retry Condition

    The condition that triggers retries. You can select one or more conditions. For more information, see the "Retry conditions" section in this topic.

    Retry Status Code

    The HTTP status codes that trigger retries. You can specify one or more HTTP status codes.

    Note

    This parameter is valid only if you select retriable-status-codes for the Retry Condition parameter.Retry Status Code

    Enable

    Specifies whether to enable the retry policy.

    • If you turn on the switch, the retry policy takes effect.

    • If you turn off the switch, the retry policy does not take effect.

    Note

    If you disable the retry policy, the gateway automatically retries a failed request for a maximum of two times based on the following conditions: connect-failure, refused-stream, unavailable, cancelled, and retriable-status-codes.

    After the retry policy is created and enabled, you can check whether the retry policy takes effect based on your business requirements.