Overview
Introduction
Cloud Functions is a cloud function service provided by Pages Functions, suitable for complex backend scenarios such as accessing external services, operating the database, and handling compute-intensive tasks.
Supported runtime
Cloud Functions supports various mainstream programming languages and runtime environments. You can select the appropriate runtime based on your business needs.
Node.js
Supports JavaScript or TypeScript development. You can access the complete npm ecosystem directly and leverage the mature Node.js toolchain to build applications.
Python
Supports development using Python and integrates third-party libraries via pip. Offers native support for mainstream Web frameworks such as Flask, FastAPI, Django, and Sanic.
Go
Leverage the excellent concurrency capability and execution performance of Golang to build high-performance backend services, and support project dependency management through Go Modules.
Note:
Multi-Region Deployment
Cloud Functions supports deployment in multiple regions. You can choose the region for function execution and deploy functions closer to the data source, thereby reducing network latency and improving response speed.
Note:
Multi-region deployment is applicable only to Cloud Functions.
Region Selection
The region configuration of Cloud Functions is related to the Acceleration Region of the project:
Global availability zone (including Chinese mainland): You can configure regions in Chinese mainland and regions outside Chinese mainland separately.
Chinese mainland availability zone: Only require configuration for Chinese mainland.
Global availability zone (excluding Chinese mainland): Only require configuration for regions outside Chinese mainland.
By default, the Chinese mainland region is
ap-guangzhou (Guangzhou), and regions outside the Chinese mainland are ap-singapore (Singapore).Optional Region List
Chinese mainland:
Region name | Region ID |
Guangzhou | ap-guangzhou |
Shanghai | ap-shanghai |
Nanjing | ap-nanjing |
Beijing | ap-beijing |
Chengdu | ap-chengdu |
Regions outside Chinese mainland:
Region name | Region ID |
Singapore | ap-singapore |
Hong Kong (China) | ap-hongkong |
Bangkok | ap-bangkok |
Jakarta | ap-jakarta |
Seoul | ap-seoul |
Tokyo | ap-tokyo |
Frankfurt | eu-frankfurt |
Virginia | na-ashburn |
Silicon Valley | na-siliconvalley |
Configuration Method
Configure in the console
In the Pages console project setting, select the deployment region in function management.
Configure in edgeone.json
In the
edgeone.json file, specify the function deployment region through the mainlandRegions and overseasRegions fields, and configure as needed based on the acceleration region of the project.{"mainlandRegions": ["ap-beijing"],"overseasRegions": ["ap-tokyo"]}
Note:
Each field in the array can only be configured with one region.
edgeone.json: The region configuration priority in edgeone.json is higher than the console configuration.
Use Limits
The following are the general restrictions and runtime version info for Cloud Functions:
Content | Limitation | Note |
Code package size | 128 MB | Single function code package size (including dependencies) supports up to 128 MB. |
Request body size | 6 MB | Client requests carry a body with a maximum of 6 MB. |
maximum execution time | 120s | Maximum Duration from the start of a single request to the response. |
Node.js version | v20.x | Default Node.js runtime version |
Python version | 3.10 | The server runtime environment is Python 3.10. We recommend using the same version for local development. |
Go version | 1.26 | Runtime environment version 1.26 (backward compatibility) |
Note:
When involved in file transfer, it is not recommended to store data that needs long-term retention. We recommend using Tencent Cloud COS to handle persistence needs.
