Cloud-native API Gateway allows you to configure route-level retry policies. This allows you to configure automatic retries for failed requests. 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 the specified number of times.
Retry conditions for HTTP requests:
5xx: The backend service returns a
5xxstatus code, or a disconnection, reset, or read timeout event occurs.NoteThe
5xxcondition includes theconnect-failureandrefused-streamconditions.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_STREAMstatus 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-codesas a retry condition.
Retry conditions for gRPC requests:
cancelled: The
CANCELLEDstatus 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
INTERNALstatus code is contained in the header of the response from the backend gRPC service.resource-exhausted: The
RESOURCE_EXHAUSTEDstatus code is contained in the header of the response from the backend gRPC service.unavailable: The
UNAVAILABLEstatus code is contained in the header of the response from the backend gRPC service.
Configure a retry policy
Log on to the Cloud-native API Gateway console.
In the left-side navigation pane, click API. In the top navigation bar, select a region.
Click the target API. On the API details page, click the name of the target route. Click the Configure Policy tab and click Retry on the left.
On the Retry tab, configure the parameters and click Save.
Parameter
Description
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.
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.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 Conditions
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-codesfor the Retry Conditions parameter.Retry Status CodeAfter the retry policy is created and enabled, you can check whether the retry policy takes effect based on your business requirements.