Configure a retry policy
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.
-
Retry conditions for the HTTP protocol:
-
5xx: The backend service returns a
5xxresponse, or a connection is disconnected, reset, or times out during a read operation.NoteThe
5xxcondition includes theconnect-failureandrefused-streamconditions. -
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_STREAMerror code. -
retriable-status-codes: The HTTP status code in the response matches a specified retry status code.
NoteYou can use retry status codes only if
retriable-status-codesis 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
-
You can configure a retry policy in two ways, depending on how your API is managed:
API outside an instance
-
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.
-
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.
-
In the Routes, click the target route.
API inside an instance
-
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.
-
On the Instance page, click the target gateway instance. In the navigation pane on the left, click API, and then click the target API.
-
In the Routes, click the target route.
-
-
Click the Configure Policy tab. In the Inbound Processing section, click Enable Policy/Plug-in.
-
Click the Retry card. In the Add Policy: Retry panel, configure the parameters and click Add.
NoteAfter 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.
NoteIf 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, andretriable-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.
NoteA 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.
NoteYou can configure the Retry Status Code parameter only if
retriable-status-codesis selected for Retry Condition. -