All Products
Search
Document Center

Function Compute:Asynchronous invocations

Last Updated:Apr 01, 2026

When a function contains logic that is time-consuming, resource-intensive, or error-prone, asynchronous invocations let you process requests without blocking the caller. Function Compute immediately returns a response, persists the request in an internal queue, and processes it in the background — even under traffic spikes.

Use cases

  • Audio and video processing: Encoding, decoding, and transcoding are slow operations. Run them in the background so the frontend stays responsive. Use concurrent async invocations to split large projects into parallel tasks.

  • ETL pipelines: For extract, transform, and load (ETL) workloads — database queries, file operations, data cleansing — async invocations let independent steps run in parallel and keep large-scale transformations off the critical path.

  • Web applications: Prevent page freezing when users submit forms, run queries, or load large datasets. Under high concurrency, async invocations distribute request load to prevent service overload.

Trigger an async invocation

Use any of the following methods:

  • Console: On the Tests tab, select Invoke the function in asynchronous mode.

    image

  • API: Call InvokeFunction with the x-fc-invocation-type: Async header.

  • HTTP or custom domain: Set the X-Fc-Invocation-Type: Async request header:

    curl -v -H "X-Fc-Invocation-Type: Async" https://example.cn-shenzhen.fcapp.run/$path
  • Serverless Devs: Set invocation-type to Async. See Invoke a function.

  • Triggers: Create a trigger that supports async invocations. See Trigger tasks by using events.

Deferred invocations

To delay a function execution after submitting an async request, add the x-fc-async-delay HTTP header to your invocation. Set the value to the desired delay in seconds. Valid values: (0, 3600).

Function Compute invokes the function after the specified delay elapses.

Retry policy

Function Compute automatically retries failed async invocations. The retry behavior depends on the error type.

Default retry behavior

Error typeRetry behaviorBilled
HandledInvocationError / UnhandledInvocationErrorRetried up to 3 times (configurable, range: [0, 8]).Yes — billed per invocation. See Billing overview.
Concurrency limit exceededRetried for up to 5 hours using binary exponential backoff. Initial interval: 0.5 s; subsequent intervals double (1 s, 2 s, 4 s, 8 s, ...).No
Internal errorNot retried. Join the DingTalk group (ID: 64970014484) for support.No
Insufficient Function Compute resourcesNot retried.No

By default, each Alibaba Cloud account can run up to 100 instances per region. To increase this quota, visit the Quota Center console.

Configure the retry policy

Set the maximum retry count and message lifetime for a function in the console.

  1. Log on to the Function Compute console. In the left-side navigation pane, click Functions.

  2. Select a region. On the Functions page, click the function you want to configure.

  3. On the Function Details page, go to the Tasks tab. In the Task Mode section, click Modify.

  4. Adjust the parameters in the Task Mode panel, then click Deploy.

ParameterDescription
Task ModeEnables or disables asynchronous task mode. See Asynchronous tasks.
Maximum RetriesMaximum number of retries for HandledInvocationError and UnhandledInvocationError. Valid values: [0, 8]. Default: 3.
Maximum Message LifetimeHow long Function Compute retains a request in the queue before discarding it. Applies to all retry types. Valid values: [1, 604800]. Default: 86400. Unit: seconds. The timer starts when the async invocation is triggered. Discarded messages are tracked by the Asynchronous Invocation Trigger Events metric in CloudMonitor. See Monitoring metrics.

Result callbacks

After Function Compute accepts an async request, it persists the request and immediately returns a response. Configure a result callback to handle requests that exhaust all retries, or to notify downstream services after execution.

When configured, Function Compute sends the request context to the specified destination service based on the invocation outcome.

How it works

image

Supported destination services

Function Compute can route invocation results to the following destination services:

  • Simple Message Queue (formerly MNS)

  • Function Compute

  • EventBridge

  • ApsaraMQ for RocketMQ

Only ApsaraMQ for RocketMQ 4.x instances are supported as destination services. 5.x instances cannot be configured. See Differences and compatibility between versions 4.x and 5.x.

Configure separate destinations for successful and failed invocations. See Function runtime resource limits for payload limits by destination service.

Event payload

When Function Compute triggers a callback, it sends a JSON payload to the destination. The payload structure differs by destination service.

For Simple Message Queue (formerly MNS), Function Compute, and ApsaraMQ for RocketMQ:

{
  "timestamp": 1660120276975,
  "requestContext": {
    "requestId": "xxx",
    "functionArn": "acs:fc:{regionid}:{accountid}:functions/xxxx",
    "condition": "FunctionResourceExhausted",
    "approximateInvokeCount": 3
  },
  "requestPayload": "",
  "responseContext": {
    "statusCode": 200,
    "functionError": ""
  },
  "responsePayload": ""
}
FieldDescription
timestampTimestamp of the invocation.
requestContext.requestIdRequest ID of the async invocation.
requestContext.functionArnARN (Alibaba Cloud Resource Name) of the invoked function.
requestContext.conditionError code of the invocation.
requestContext.approximateInvokeCountTotal execution count. A value greater than 1 means the invocation was retried.
requestPayloadOriginal request payload.
responseContext.statusCodeSystem status code. A value other than 200 indicates a system error.
responseContext.functionErrorError message from the invocation.
responsePayloadResponse payload returned by the function.

For EventBridge:

For the EventBridge payload format and field reference, see Event overview. The type field is set to fc:AsyncInvoke:succeeded for successful invocations.

{
    "datacontenttype": "application/json",
    "aliyunaccountid": "143xxxx",
    "data": {
        "requestContext": {
            "condition": "",
            "approximateInvokeCount": 1,
            "requestId": "0fcb7f0c-xxxx",
            "functionArn": "acs:fc:{regionid}:{accountid}:functions/xxxx"
        },
        "requestPayload": "",
        "responsePayload": "",
        "responseContext": {
            "functionError": "",
            "statusCode": 200
        },
        "timestamp": 1660120276975
    },
    "subject": "acs:fc:{regionid}:{accountid}:functions/xxxx",
    "source": "acs:fc",
    "type": "fc:AsyncInvoke:succeeded",
    "aliyunpublishtime": "2021-01-03T09:44:31.233Asia/Shanghai",
    "specversion": "1.0",
    "aliyuneventbusname": "xxxxxxx",
    "id": "ecc4865xxxxxx",
    "time": "2021-01-03T01:44:31Z",
    "aliyunregionid": "cn-shanghai-vpc",
    "aliyunpublishaddr": "199.99.xxx.xxx"
}

Payload limits

Destination servicePayload limit
Simple Message Queue (formerly MNS)64 KB
Function ComputeSee Function runtime resource limits
EventBridge64 KB
ApsaraMQ for RocketMQ4 MB

Configure destination services

  1. Log on to the Function Compute console. In the left-side navigation pane, click Functions.

  2. Select a region. On the Functions page, click the function you want to configure.

  3. On the Function Details page, go to the Tasks tab. In the Task Destination section, click Modify.

  4. In the Task Destination panel, configure destinations for successful and failed invocations, then click Deploy.

Destination for successful invocations:

In the Destination for Successful Invocations panel, set Invoke Other Services upon Success to Enable, then configure Destination Service.

Destination serviceRequired parameters
Function ComputeFunction Name, Version or Alias
Simple Message Queue (formerly MNS)Destination Type (Queue or Topic); Queue name (if Queue) or Topic name (if Topic)
ApsaraMQ for RocketMQInstances, Topic
EventBridgeCustom Event Bus

Destination for failed invocations:

In the Destination for Failed Invocations panel, set Invoke Other Services upon Failure to Enable, then configure Destination Service using the same parameters above.

Avoid invocation loops

If Function A sends successful results to Function B, and Function B sends successful results back to Function A, any invocation of Function A starts an infinite loop. Design your destination chains to be acyclic.

Handle callback failures

If Function Compute cannot deliver a callback — for example, due to missing permissions or an unavailable destination — it retries or records the failure based on the HTTP status code returned by the destination.

HTTP status codeCauseSystem behavior
5xxThrottling or content errorAutomatic retry in exponential backoff mode. Initial interval: 500 ms; maximum retry duration: 30 minutes.
4xxMissing permissions, invalid parameter, or payload exceeds the destination's limitReturns an error and records the error message. No retry.

Monitor callback failures:

To view callback metrics, log on to the Function Compute console. In the left-side navigation pane, choose Advanced Features > Monitoring Metrics, then click the function name.

MetricDescription
FunctionDestinationErrorsNumber of requests that failed to trigger the destination. Collected per minute or per hour.
FunctionDestinationSucceedNumber of requests that successfully triggered the destination. Collected per minute or per hour.

For the full metrics reference, see Monitoring metrics.

What's next

To track the status of each async request through its lifecycle, enable task mode. See Asynchronous tasks.