CloudBase Cloud Function Overview
CloudBase cloud function is a serverless computing service provided by Tencent Cloud TCB, enabling you to focus on business logic development without managing servers. Write code, upload, run — it's that simple.
Basic Features
CloudBase cloud function is a code snippet running in the cloud that automatically executes when an event occurs. You only need to write business logic, and CloudBase is responsible for server management, scale-out and scale-in, and Ops.
Core Capabilities:
- 🚀 Event-Driven Execution - Automatically triggered by HTTP requests, data changes, or scheduled tasks
- ⚡ Automatically Scale - Automatically adjusts based on request volume, with a maximum concurrency of 1000
- 💰 Pay-as-you-go - Pay only for what you use, no cost when idle
- 🔗 Service Integration - Seamlessly integrated with databases, storage, and authentication
Supported Languages: Node.js, Python, Java, Go, PHP
Function type:
- Regular Cloud Function - Handles structured business logic, suitable for API interfaces and data processing
- HTTP Cloud Function - Full-fledged Web service capabilities, suitable for Web applications and file upload
Working Principle
Execution Flow
User request → Event triggered → Function instance starts up → Code execution → Result returned → Instance recycled
- Event Triggering - HTTP requests, database changes, scheduled tasks, and other events trigger functions
- Instance Management - CloudBase automatically creates function instances and loads the code
- Code Execution - Executing business logic in an isolated environment
- Service Invocation - Accessing cloud services such as databases and storage via SDK
- Result Return - Returns the result after processing, and instances are automatically recycled
Trigger Methods
| Trigger Methods | Description | Use Cases |
|---|---|---|
| SDK Invocation | Direct client SDK invocation | Mini Programs, Web applications |
| HTTP Request | Invoked via HTTP API | Third-party system integration |
| Timer Trigger | Automatically executes based on time schedules | Data statistics, system maintenance |
Runtime Environment Features
- Isolation - Each function runs in an independent container environment
- Stateless - Function instances do not share state
- Ephemeral - Instances are automatically recycled after execution
- Elasticity - Automatically creates and destroys instances based on workload
Development Workflow
🔗 1. Environment Preparation
Register a Tencent Cloud account, install the CloudBase CLI tool, log in and initialize the project
🔗 2. Create Function
Select the programming language and runtime version, create the function and configure basic information
🔗 3. Write Code
Write business logic code, configure the function handler and dependencies, set environment variables
🔗 4. Local Debugging
Use a local simulator to test the function, simulating different events for debugging
🔗 5. Deploy Function
Upload the code package to the cloud, configure triggers and access permissions, publish the function version
🔗 6. Test Invocation
Test the function via the CLI tool, and integrate the invocation in the client application
🔗 7. Monitoring and Ops
View function execution logs, monitor performance metrics, set alarms and scale-out and scale-in policies
Quick Start
- Quick Start - Create your first function in 5 minutes
- Development Guide - Detailed development documentation
- Sample Code - Rich sample repository
- Web Console - visual management page
Example
📄️ Express
How to deploy an Express application sample on HTTP cloud functions
📄️ Nest.js
How to deploy a Next.js application sample on HTTP cloud functions
📄️ NestJS
How to deploy a NestJs application sample on HTTP cloud functions
📄️ Flask
How to deploy a Flask application sample on HTTP cloud functions
📄️ Django
How to deploy a Django application sample on HTTP cloud functions
📄️ FastAPI
How to deploy a FastAPI application sample on HTTP cloud functions