When an asynchronous invocation of a function fails to be executed, Function Compute retries the execution. This topic describes the retry mechanism and how to configure
retry policies in the Function Compute console.
Retry mechanism
The following table describes the default retry policies for common errors.
HTTP status code |
Failure cause |
Server behavior |
200 |
An error of the HandledInvocationError or UnhandledInvocationError type occurs. For more information, see Basics.
|
By default, the system retries the execution three times or retries the execution
based on the setting of maxAsyncRetryAttempts in the asynchronous invocation configurations.
|
429 |
Requests are throttled because the maximum number of concurrent requests has been
reached.
|
Function Compute retries the execution for up to five hours in the binary exponential
backoff mode. Function Compute retries the execution for up to five hours in the binary
exponential backoff mode. Function Compute starts to retry a function 0.5 seconds
after the function fails to be executed. The subsequent retries are performed at binary
exponential back-off intervals, such as 1 second, 2 seconds, 4 seconds, and 8 seconds.
|
500 |
A system error occurred. |
503 |
Function Compute resources are insufficient.
|
Configure a retry policy
You can specify the maximum number of retries and the maximum lifetimes of messages
in Function Compute.
- Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
- In the top navigation bar, select a region. On the Services page, click the desired service.
- On the Functions page, click the function that you want to modify.
- On the function details page, click the Asynchronous Mode Configurations tab. In the Asynchronous Policy section, click Modify.
- In the Modify the Policy for Asynchronous Mode panel, configure the parameters and click OK.
Parameter |
Description |
Task Mode |
Specifies whether to enable the asynchronous task mode. For more information, see
Overview.
This parameter is optional. You do not need to set this parameter when you configure
a retry policy.
|
Maximum Retries |
The maximum number of retries for the messages in an asynchronous invocation process.
Valid values: [0,8].
By default, Function Compute retries a failed asynchronous invocation up to three times. You can adjust the maximum
number of retries based on your business needs.
|
Maximum Message Lifetime |
The validity period of messages in an asynchronous invocation process. Valid values:
[1,2592000]. Unit: seconds.
The period starts when an asynchronous invocation is triggered and ends when the message
is removed from the queue for processing. The message is discarded when the maximum
lifetime elapses. Discarded messages are tracked by the Asynchronous Invocation Trigger Events metric in CloudMonitor. For information about metrics, see Monitoring metrics.
Note The maximum validity period of messages. By default, the maximum validity period is
1 day.
|