When you initiate an asynchronous call to a function, the related requests are persisted to the Function Compute internal queue and then reliably processed. If you want to track and save the status of each phase of an asynchronous call to enable task control and observability, you can enable task mode to process asynchronous requests. This topic describes the background information, limits, and common features of asynchronous tasks.

Background information

After you enable asynchronous tasks, you can implement the following features:
  • Each function call will record in detail the state transition information during the call, such as call input, execution result, and error information.
  • It has call-level control capabilities and can actively terminate calls.

Asynchronous tasks save state information. Therefore, the invocation and execution of functions have a certain additional delay, which does not incur additional costs. For more information about the billing of Function Compute, see Billing.

Limits

  • Scenario limits
    Although asynchronous tasks are more functional, they have greater system overhead. We recommend that you disable the task mode in the following scenarios:
    • You are very sensitive to request processing link latency. You need an average latency of less than 100 milliseconds.
    • You need to initiate asynchronous calls at a rate of thousands or more per second.
  • Supported regions

    Asynchronous tasks support the China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), China (Hong Kong), Singapore, UK (London), US (Silicon Valley), US (Virginia), Germany (Frankfurt), Australia (Sydney), and India (Mumbai) regions.

  • Validity period

    You can query only the task status information within seven days.

Comparison of features

If you want to build an asynchronous task processing platform or implement simple scheduled tasks, you can use the Jobs feature of Kubernetes. The following is a comparison between Function Compute asynchronous tasks and the Jobs feature of Kubernetes.

Feature Function Compute asynchronous tasks Jobs feature of Kubernetes
Scenarios It is applicable to real-time tasks with a task execution duration of tens of milliseconds and offline tasks with a task execution duration of tens of hours. It is suitable for offline tasks with low task submission speed, fixed task load, and low real-time task requirements.
Mission observability Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Provides metrics such as logs and the number of queued tasks, and rich observability such as task link duration and task status query. You need to integrate open source software to implement it.
Automatic scaling of task instances Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Automatically scale in based on the number of task queues and instance resource usage. You must use task queues to implement self-scaling and instance SLB, which is highly complex.
Scaling speed of task instances in milliseconds. Allows you to scale the database system within a few minutes.
Resource utilization of task instances You only need to select an appropriate instance type. The instance auto scaling is measured based on the duration of the actual processing task. The resource utilization is high. You must determine the specifications and number of instances when Jobs is submitted. Instances are difficult to auto scaling and SLB, and resource utilization is low.
Task submission speed A single user can submit tens of thousands of tasks per second. The entire cluster can start a maximum of several hundred jobs per second.
Scheduled or delayed task submission Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Scheduled task submission is supported. Delayed task submission is not supported.
Task deduplication Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. No,
Suspend or resume task execution Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Only Kubernetes 1.21 and later versions are supported.
Terminate a specified task Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Limited support. This is achieved indirectly by terminating a task instance.
Task flow control Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. Flow control can be performed at different granularities such as user or task processing functions. No,
Automatic callback for task results Yes, Anti-DDoS Pro and Anti-DDoS Premium support WebSocket. No,
Development O&M costs You only need to implement the processing logic of the task. You must maintain the K8s cluster.

Common Features

Common features of asynchronous tasks are as follows: