Configure a retry policy

更新时间: 2026-07-17 22:26:20

Cloud-native API Gateway supports route-level retry policies to automatically retry failed requests. You can configure retry conditions based on connection failures, unavailable backend services, or specific HTTP status codes.

Retry conditions

When a backend service returns a 5xx error, Cloud-native API Gateway automatically retries the request up to the configured number of times.

image
  • Retry conditions for the HTTP protocol:

    • 5xx: The backend service returns a 5xx response, or a connection is disconnected, reset, or times out during a read operation.

      Note

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

    • reset: A connection is disconnected, reset, or times out during a read operation.

    • connect-failure: A request fails because the connection is disconnected.

    • refused-stream: The backend service resets a stream with a REFUSED_STREAM error code.

    • retriable-status-codes: The HTTP status code in the response matches a specified retry status code.

      Note

      You can use retry status codes only if retriable-status-codes is specified in the retry condition.

  • Retry conditions for the gRPC protocol:

    • cancelled: The gRPC status code in the response header is cancelled.

    • deadline-exceeded: The gRPC status code in the response header is deadline-exceeded.

    • internal: The gRPC status code in the response header is internal.

    • resource-exhausted: The gRPC status code in the response header is resource-exhausted.

    • unavailable: The gRPC status code in the response header is unavailable.

Configure a route retry policy

  1. You can configure a retry policy in two ways, depending on how your API is managed:

    API outside an instance

    1. Log in to the Cloud-native API Gateway console. In the navigation pane on the left, click API, and then select a region from the top menu bar.

    2. On the HTTP API page, use the drop-down list at the top to select the target instance. You can select a specific instance or All instances.

    3. In the Routes, click the target route.

    API inside an instance

    1. Log in to the Cloud-native API Gateway console. In the navigation pane on the left, click Instance, and then select a region from the top menu bar.

    2. On the Instance page, click the target gateway instance. In the navigation pane on the left, click API, and then click the target API.

    3. In the Routes, click the target route.

  2. Click the Configure Policy tab. In the Inbound Processing section, click Enable Policy/Plug-in.

  3. Click the Retry card. In the Add Policy: Retry panel, configure the parameters and click Add.

    Note

    After configuring and enabling the retry policy, verify that it works as expected.

    Parameter

    Description

    Enable

    Enables or disables the retry policy.

    • Enabled: The retry policy is active.

    • Disabled: The retry policy is inactive.

    Note

    If this policy is disabled, the gateway uses a default retry configuration. The default number of retries is 2, and the default retry conditions are connect-failure, refused-stream, unavailable, cancelled, and retriable-status-codes.

    Retry Times

    The maximum number of retries for a failed request. Valid values: 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 retry. You can select multiple conditions. For more information, see Retry conditions.

    Retry Status Code

    The HTTP status codes that trigger a retry. You can specify multiple codes.

    Note

    You can configure the Retry Status Code parameter only if retriable-status-codes is selected for Retry Condition.

上一篇: Configure a timeout policy 下一篇: Configure a consumer authentication policy