When you invoke a function asynchronously, the related requests are persisted to the Function Compute queue before they are processed in a reliable manner. If you want to track and save the status of asynchronous invocations in each phase to obtain better task control capabilities and observability, you can enable the task mode to process asynchronous requests. This topic describes the background information, limits, and common features of asynchronous tasks.
- The system records detailed status transition information of each invocation, such as the invocation input, execution result, and error messages.
- You can manage each invocation. For example, you can terminate an invocation.
Higher latency is incurred for invoking and executing a function when the asynchronous task feature is enabled because status information needs to be saved. The latency does not cause additional fees. For more information about the billing of Function Compute, see Billing overview.
- Scenario limits
Although the asynchronous task feature provides more capabilities, more system overheads are incurred. We recommend that you disable the asynchronous task feature in the following scenarios:
- Your business applications are sensitive to the latencies of request processing links and require the average latency to be less than 100 milliseconds.
- You need to initiate at least thousands of asynchronous invocations per second.
- Limits on regions
The asynchronous task mode is supported in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), China (Hong Kong), Singapore (Singapore), UK (London), US (Silicon Valley), US (Virginia), Germany (Frankfurt), Australia (Sydney), and India (Mumbai).
- Validity period
You can query task information only within seven days.
If you want to build an asynchronous task processing platform or run simple scheduled tasks, you can use Kubernetes Jobs. The following is a comparison between Function Compute asynchronous tasks and Kubernetes Jobs.
|Item||Asynchronous task in Function Compute||Kubernetes Jobs|
|Scenario||Applies to real-time tasks that last tens of milliseconds and offline tasks that last tens of hours.||Applies to offline tasks with low requirements on the task submission speeds, fixed task loads, and low requirements on timeliness.|
|Observability||Supported. Metrics, such as logs and the number of queued tasks, and the observability capabilities, including the query of task link durations and task status, are provided.||You must integrate open source software to implement the observability capabilities.|
|Automatic scaling of task instances||Supported. Automatic scaling based on the number of queued tasks and instance resource usage can be performed.||You must use task queues to manually implement scaling and load balancing of instances, which is more complicated.|
|Scaling speed of task instances||In milliseconds.||In minutes.|
|Resource utilization of task instances||You need to only select the instance type. The instances are automatically scaled. You are charged based on the actual task-processing durations. The resource utilization is high.||You must determine the specifications and number of instances when Jobs are submitted. It is difficult to implement auto scaling and load balancing of instances. The resource utilization is low.|
|Task submission speed||A single user can submit tens of thousands of tasks per second.||Up to hundreds of Jobs can be started in a cluster per second.|
|Scheduled or deferred task submission||Supported.||Scheduled task submission is supported. Deferred task submission is not supported.|
|Task deduplication||Supported.||Not supported.|
|Task termination||Supported.||Supported under certain conditions. You can terminate a task by terminating a task instance.|
|Task throttling||Supported. Throttling can be performed at different granularities, such as at the user level or at the task-processing function level.||Not supported.|
|Automatic result callback for a task||Supported.||Not supported.|
|Development and O&M costs||You need to only implement the processing logics of tasks.||You must maintain the Kubernetes cluster.|
See the following topics to learn about common features of asynchronous tasks: