To meet business requirements in different scenarios, Function Compute provides two types of functions: event functions and HTTP functions. This topic describes the scenarios of and differences between the two types of functions in Function Compute.
Comparison
Function Compute supports two types of functions: event functions and HTTP functions.
Event functions are suitable for scenarios in which events are used to invoke functions in event-driven models.
HTTP functions are suitable for scenarios such as quick building of web applications.
In the programming models of Function Compute, the model of a handler consists of three parts: the function name, the function input parameters, and responses. You can also pass another function defined in the code as an input parameter to the handler.
The following table lists the differences between event functions and HTTP functions in terms of trigger methods and input parameters.
Function type | Trigger method | Input parameter |
Event functions | You can trigger the execution of an event function to implement a specific feature. To trigger an event function, you can configure a timer, call API operations or use SDKs, or use triggers of other Alibaba Cloud services. You can create various triggers other than HTTP triggers, such as Object Storage Service (OSS) triggers, Log Service triggers, Alibaba Cloud CDN triggers, Tablestore triggers, and EventBridge triggers. For more information about the supported trigger types, see Trigger overview. All supported types of triggers can be used to trigger event functions. | The following code defines a simple Node.js handler:
For more information about Node.js event functions, see Event handlers. For more information about the input parameters of functions in other programming languages, see Overview. |
HTTP functions | HTTP functions can be triggered only by HTTP or HTTPS requests. You can specify the request methods that can trigger an HTTP function, such as GET, POST, PUT, DELETE, HEAD, and PATCH, based on your business requirements, Function Compute allows you to create an HTTP trigger that triggers an HTTP function by sending HTTP or HTTPS requests. Only one HTTP trigger can be created for one version or one alias of a service. For more information, see Overview. | The following code defines a simple Node.js handler:
For more information about Node.js HTTP functions, see HTTP handlers. For more information about the input parameters of functions in other programming languages, see Overview. |