All Products
Search
Document Center

Function Compute:Selection of methods to create functions

Last Updated:Jul 25, 2024

Function Compute allows you to create event functions, web functions, and task functions to meet your business requirements in different scenarios. This topic describes the common scenarios and differences of different function creation methods in Function Compute.

Comparison

Item

Event function

Web function

Task function

Scenarios

Write programs to handle events based on the interfaces defined in Function Compute.

Write programs based on popular frameworks, such as Java Spring Boot, Node.js Express, Python Flask, and Golang Gin, or migrate applications deployed on existing frameworks.

Container images

  • Exercise full control over the environment in which your programs run, or migrate existing containerized applications.

  • Use GPU-accelerated instances.

Invoke a function in asynchronous invocation mode and track and save the status of each phase of the asynchronous invocation. By default, the task mode is enabled for task functions. You can use the task mode to submit, view, stop, and retry asynchronous tasks.

Cold start duration

Shortest. The durations of cold starts are the shortest because runtimes are not included in code packages.

Short. Web functions use public images and have no image pull time, which accelerates cold starts.

Long. The durations of cold starts are relatively longer because image pulling takes time.

Shortest. The durations of cold starts are also the shortest because runtimes are not included in code packages.

Upper limit of code package size

500 MB compressed code package.

500 MB compressed code package.

10 GB compressed image.

500 MB compressed code package.

Code package formats

ZIP, JAR (Java), and folder.

ZIP, JAR (Java), and folder.

See What is Container Registry?

ZIP, JAR (Java), and folder.

GPU-accelerated instances

Not supported.

Not supported.

Supported.

Not supported.

Runtimes

Node.js, Python, PHP, Java, .NET Core, and Go.

Unlimited.

Unlimited.

Node.js, Python, PHP, Java, .NET Core, and Go.

Function types

Event functions

If you want to write programs to handle events based on the interfaces defined in Function Compute, create an event function. For more information, see Create an event function.

image

Web functions

If you want to write programs based on popular frameworks, such as Java Spring Boot, Node.js Express, Python Flask, and Golang Gin, create functions based on custom container images, or migrate existing framework-based applications, create a web function. For more information, see Create a web function.

image

Task functions

If you want to invoke your function in asynchronous mode and need to track and save the status of each phase of asynchronous invocations, you can create a task function. By default, the task mode is enabled for task functions. You can use the task mode to submit, view, stop, and retry asynchronous tasks. For more information, see Create a task function.

image