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.NoteThe
5xx
condition includes theconnect-failure
andrefused-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.
NoteYou 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
Log on to the MSE console. In the top navigation bar, select a region.
In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.
In the left-side navigation pane, click Routes, and click the Routes tab.
On the Routes tab, find the routing rule that you want to modify, and click Policies in the Actions column.
On the Policies tab, click Retry.
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.
NoteIf 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.
NoteThis parameter is valid only if you select
retriable-status-codes
for the Retry Condition parameter.Retry Status CodeEnable
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.
NoteIf 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
, andretriable-status-codes
.After the retry policy is created and enabled, you can check whether the retry policy takes effect based on your business requirements.