Configure a retry policy

更新时间:
复制 MD 格式

A cloud-native gateway lets you configure a route-level retry policy to automatically retry failed requests. You can specify retry triggers, such as connection failures, an unavailable backend service, or responses with specific HTTP status codes.

Route retry conditions

If a backend service returns a 5xx error, the cloud-native gateway automatically retries the request up to the configured number of times.

路由重试

  • The following retry conditions are available for the HTTP protocol:

    • 5xx: The cloud-native gateway retries the request if the backend service returns a 5xx response, or if a disconnection, reset, or read timeout occurs.

      Note

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

    • reset: The cloud-native gateway retries the request if a disconnection, reset, or read timeout occurs.

    • connect-failure: The cloud-native gateway retries the request if it fails due to a connection failure.

    • refused-stream: The cloud-native gateway retries the request if the backend service resets the stream with a REFUSED_STREAM error code.

    • retriable-status-codes: The cloud-native gateway retries the request if the response's HTTP status code matches a specified retry status code.

      Note

      You can specify retry status codes only if retriable-status-codes is selected as a retry condition.

  • The following retry conditions are available for the gRPC protocol:

    • cancelled: The cloud-native gateway retries the request if the gRPC status code in the response header is cancelled.

    • deadline-exceeded: The cloud-native gateway retries the request if the gRPC status code in the response header is deadline-exceeded.

    • internal: The cloud-native gateway retries the request if the gRPC status code in the response header is internal.

    • resource-exhausted: The cloud-native gateway retries the request if the gRPC status code in the response header is resource-exhausted.

    • unavailable: The cloud-native gateway retries the request if the gRPC status code in the response header is unavailable.

Configure a route 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 ID of the gateway.

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

  4. Find the desired route and click Policies in the Actions column.

  5. On the Policies page, click Retry.

  6. On the Retry panel, configure the parameters and click Save.

    Parameter

    Description

    Retry Times

    The maximum number of times a failed request is retried. The value must be an integer from 0 to 10. A value of 2 or less is recommended.

    Note

    A value of 0 disables retries.

    Retry Condition

    The conditions that trigger a request retry. You can select one or more conditions. For details, see Route retry conditions.

    Retry Status Code

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

    Note

    To configure the Retry Status Code, you must specify retriable-status-codes for the Retry Condition.

    Enable

    Enables or disables the route retry policy.

    • Enable: The route retry policy is active.

    • Disable: The route retry policy is inactive.

    Note

    If this policy is disabled, the gateway uses a default retry configuration. The default configuration retries a request up to two times for the following conditions: connect-failure, refused-stream, unavailable, cancelled, and retriable-status-codes.

    After you configure and enable the retry policy, verify that it functions as expected.