All Products
Search
Document Center

Function Compute:Overview

Last Updated:Feb 02, 2024

This topic describes the background information and scenarios in which asynchronous invocations can be used. This topic also describes how to defer the invocation of a function.

Background information

When Function Compute receives an asynchronous invocation request, Function Compute returns a response immediately after the request is persisted instead of waiting for the request to be completed before a response is returned. Function Compute ensures that the request is executed at least once. To obtain the results of the asynchronous invocation, you can configure destinations for the asynchronous invocation. For more information, see Result callback.

Scenarios

If your function contains logic that is time-consuming, resource-consuming, or error-prone, you can use asynchronous invocations to allow your programs to respond to traffic spikes more quickly and reliably. Example:

  • In a user registration system, a new user sends a registration request. After the registration is successful, the system sends email notifications to the user. The action of sending an email can be separated from the registration process and executed asynchronously.

  • When you upload a file, actions such as format conversion and import and export can be separated from the data upload process and executed asynchronously.

Note

HTTP functions can be invoked in a synchronous or an asynchronous way. For more information, see Overview.

Deferred invocation of a function

In some scenarios, after you submit an asynchronous invocation request, you may want Function Compute to defer the invocation. In this case, you can use the Function Compute API or SDK to defer the invocation.

Add the HTTP request header x-fc-async-delay to the function code. Valid values: (0,3600). Unit: seconds. Function Compute invokes the function after the period specified by x-fc-async-delay elapses.

Common features

For more information about the common features of asynchronous invocations, see the following topics: