To accommodate various user requirements across different scenarios, Function Compute offers four types of functions: event, web, task, and GPU. This topic describes the scenarios and distinctions among the supported function types by Function Compute, assisting you in making informed technical choices.
Overview of selection
When utilizing Function Compute, you can select the function type and runtime environment that best fit your business needs and preferred technology stack.
-
For web applications and API services, Web Functions paired with Custom Runtimes are ideal. These functions support a wide range of popular web application frameworks and can be accessed via a browser or directly through a URL.
-
For file processing and data stream processing scenarios, it is recommended to use Event Functions combined with Built-in Runtimes. You can configure event triggers and integrate with various Alibaba Cloud products such as Object Storage Service, ApsaraMQ for RocketMQ, Simple Log Service, etc.
-
For scenarios involving chatbots and text-to-image model inference, you can utilize GPU Functions in conjunction with Custom Images to rapidly develop AI model inference services using well-known AI projects like ComfyUI, RAG, TensorRT, and others.
-
For scenarios involving scheduled tasks and audio and video transcoding as asynchronous tasks, it is advisable to utilize Task Functions in conjunction with Built-in Runtimes.
For detailed information about function types and runtime environments, please refer to the tables below.
-
Built-in Runtimes and Custom Runtimes can both be deployed to functions as code packages. For those who favor containerization, Custom Images are available as an alternative runtime environment.
-
GPU Functions only support the use of Custom Images for the runtime environment.
Analysis of selection
Function type selection
Comparison item | Event Functions | Web Functions | Task Functions | GPU Functions |
Features | Used for processing files and data streams. It can be triggered by events from various cloud products such as OSS triggers, Kafka triggers, SLS triggers, etc. | Supports popular web application frameworks. It can be accessed through a browser or invoked via a URL. | Used for processing asynchronous requests. It can track and save the status of each phase of asynchronous invocations. | Supports container images of popular AI projects such as Stable Diffusion WebUI, ComfyUI, RAG, TensorRT, etc., to quickly build AI model inference services. |
Scenarios |
|
|
|
|
Runtime environment | Recommended to use built-in runtimes | Recommended to use custom runtimes | Recommended to use built-in runtimes | Only supports custom images |
Asynchronous tasks | Disabled by default | Disabled by default | Enabled by default | Disabled by default |
Function runtime environment selection
Comparison item | Built-in runtimes | Custom runtimes | Custom images |
Development process | Write handlers based on the interfaces defined by Function Compute. | Develop applications based on web application framework templates and observe the results in real time through a public endpoint. | Upload custom images to Alibaba Cloud Container Registry, or use images that are already available in Container Registry. |
Supported instance type | CPU instances | CPU instances | CPU instances and GPU-accelerated instances |
Single-instance concurrency | Not supported | Supported | Supported |
Cold start | Shortest. The durations of cold starts are shortest because runtimes are not included in code packages. | Short. Code packages serve as HTTP server programs, which can be large in size. However, they eliminate the need to pull container images from Container Registry, which results in relatively short cold start durations. | Long. The durations of cold starts are long because image pulling takes time. |
Maximum size of code deliverables | The size of code packages cannot exceed 100 MB or 500 MB. For more information, see the referenced document. |
| |
Code deliverable format | ZIP, JAR (Java), and folder | Container image | |
Supported programming languages | Node.js, Python, PHP, Java, C#, and Go | No limits | No limits |
Create functions through the console
Event functions
To invoke associated functions using event triggers such as OSS triggers, Kafka triggers, or SLS triggers, please refer to Create event functions. For optimal performance, it is advisable to select a built-in option as the Runtime Environment .
Web functions
To develop programs using popular frameworks in a variety of languages, such as Java SpringBoot, Node.js Express, Python Flask, or Golang Gin, please refer to Create web functions. For the Runtime Environment, a custom runtime is the recommended choice.
Task functions
To invoke functions asynchronously, track, and save the status of each asynchronous invocation phase, you can create task functions. Task mode, which is enabled by default for these functions, allows you to submit, view, stop, and retry asynchronous tasks. For more information, see Create task functions. It is recommended to select built-in runtimes as the Runtime Environment.
GPU functions
To create GPU instances with container images from well-known AI projects, including Stable Diffusion WebUI, ComfyUI, RAG, and TensorRT, utilize GPU functions. For detailed instructions, see Create GPU functions. Please note that GPU functions are compatible exclusively with custom images.
References
-
For additional details on asynchronous tasks, please refer to the referenced document.
-
For additional details on instance types, see the referenced document.
-
For additional details on the single-instance concurrency feature, please refer to the referenced document.
-
To learn more about cold starts in Function Compute, see the referenced document.