This topic briefly describes how to use Function Compute. Function Compute allows you to quickly build applications by writing function code without the need to manage servers. With Function Compute, you can elastically scale computing resources.

Developer toolkit

You can create services and query logs by using command-line tools fcli and Funcraft or in the Function Compute console. For more information, see fcli, Funcraft, and How to use the console.

How it works

Before using Function Compute, you must activate Function Compute on the Product Details Page. The following workflow shows the required steps for creating a service by using Function Compute.

Workflow
  1. Create a service.
  2. Create a function, write code, and deploy an application to Function Compute.
  3. Use an event to trigger the execution of the function.
  4. View execution logs of the function.
  5. View the monitoring data of the service.

Create a service

A service is the basic unit that helps you organize and manage resources in Function Compute. You can grant permissions, configure logs, and create functions for a service.

For more information, see the following topics:

Create a function

A function is the basic unit for scheduling and running in Function Compute. It is essentially a code processing logic. To create a function in Function Compute, you must write code by using the API provided by Function Compute and then deploy the code to Function Compute as a function. Services in Function Compute correspond to microservices in the software application architecture. When you build an application in Function Compute, you must abstract the business logic into microservices as required and then implement the microservices as services in Function Compute.

You can create multiple functions for one service and set properties such as memory specifications and environment variables for each function. In addition, based on your actual business scenarios, you can determine whether to enable the initializer feature. For more information about the initializer feature, see Initializer function. This service- or function-level abstraction allows you to balance system abstraction and implementation flexibility. For example, to implement a microservice, you can use the Alibaba Cloud speech synthesis service to convert text to speech, and then combine the speech segment with images to form a video. In this case, the function that is used to convert text to speech actually calls another service, and therefore you can specify a small memory size for this function. However, the function that is used for video synthesis is computing-intensive and therefore requires a larger memory size. Therefore, you can combine functions of different specifications to implement a microservice, which reduces costs.

For more information, see the following topics:

Trigger a function execution

Function Compute supports using events to trigger the execution of functions. That is, a function is executed automatically when a specified event occurs. For example, after you configure an Object Storage Service (OSS) trigger, a function can be executed automatically when an object is added to or deleted from the corresponding OSS bucket. This facilitates processing of uploaded objects. After you configure a Log Service trigger, a function can be executed automatically when a new log is written to the corresponding Logstore in Log Service. This facilitates processing of new logs. You need to configure a trigger for a function to specify how the function is triggered by an event.

For more information, see the following topics:

If you do not configure any trigger, you can also call a function directly in the Function Compute console or by using the command-line tool fcli or SDK.

View function execution logs

Viewing logs is an important step that helps you debug a function. For more information about how to configure and view logs in Function Compute, see Logs.

View service monitoring data

You can view monitoring data of a service in the Function Compute console.

For more information, see the following topics: