Function Compute automatically retries an asynchronous invocation if the invocation fails. This topic describes the retry mechanism and how to configure a retry policy in the Function Compute console.
Retry mechanism
The following table describes the default retry mechanism for common errors.
Status code | Cause | Server behavior |
200 | An error of the | By default, the system retries the execution three times or based on the setting of maxAsyncRetryAttempts in asynchronous invocation configurations. |
429 | Requests are throttled because the maximum number of concurrent requests is reached. | Function Compute retries the execution for up to 5 hours in the binary exponential back-off mode. Retries start 0.5 seconds after a function execution failure. Subsequent retry intervals are calculated in the binary exponential backoff mode. Specifically, the wait intervals between retries double with each attempt, starting at 1 second, then 2 seconds, 4 seconds, 8 seconds, and so forth. This pattern continues for up to 5 hours. |
500 | A system error occurs. | |
503 | Function Compute resources are insufficient. |
Configure a retry policy
You can specify the maximum number of retries and the maximum time to live (TTL) for 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 Configurations tab. In the Asynchronous Policy section, click Modify.
In the Modify the Policy for Asynchronous Mode panel, configure the following parameters and click OK.
Parameter
Description
Task Mode
Specify whether to enable the asynchronous task mode. For more information, see Overview.
This parameter is optional. You do not need to configure this parameter when you configure a retry policy.
Maximum Retries
Specify the maximum number of retries for messages in asynchronous invocation processes. Valid values: [0,8].
By default, Function Compute retries three times for failed asynchronous messages. You can reduce or increase the number of retries based on your business requirements.
Maximum Message Lifetime
Specify the maximum lifetime of messages in asynchronous invocation processes. Valid values: [1,604800]. Default value: 86400. Unit: seconds.
This duration is calculated from the time when an asynchronous invocation is triggered until the message is dequeued 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 more information, see Monitoring metrics.