tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary

Function Overview

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-12-02 20:07:18
HTTP-triggered function is a function type in SCF. Compared with event-triggered function that has limits on the event format, HTTP-triggered function focuses on optimization of web service scenarios and can directly send HTTP requests to URLs to trigger function execution.

Features and Advantages

In terms of the support for web service scenarios, HTTP-triggered function excels event function in the following aspects:
Functions can directly receive and process HTTP or WebSocket requests, so API Gateway doesn't need to convert the requests to JSON format, which reduces the request processing steps and improves the web service performance.
The writing experience of HTTP-triggered function is closer to that of native web services, and native Node.js APIs can be used to deliver a service experience consistent with that of local development.
A rich set of frameworks are supported. You can use common web frameworks, such as Node.js web frameworks Express and Koa, to write HTTP-triggered functions. You can also quickly migrate your local web framework services to the cloud with minimal modification.
An HTTP-triggered function can automatically create an API Gateway service for you. After the deployment is completed, API Gateway will automatically generate a default URL for user access and invocation, which reduces the learning costs and simplifies debugging.
The SCF console provides testing capabilities for you to quickly test your services.

How It Works

How an HTTP-triggered function works is as shown below:

After your HTTP request passes API Gateway, when directly passing through the native request, API Gateway will add the content required by the gateway to trigger the function, such as function name and function region, to the request header and pass the modified request to the function environment to trigger the backend function.
In the function environment, the built-in proxy is used to implement Nginx-based forwarding, remove the request information not required by the service specification from the header, and send the native HTTP request to your web server service through the specified port.
After being configured with the specified listening port 9000 and service bootstrap file, your web server will be deployed in the cloud and use this port to get HTTP requests for processing.

Usage Limits

Feature limits

Currently, HTTP-triggered functions can be bound to only API Gateway triggers.
A function can be bound to multiple API Gateway triggers, but all APIs must be under the same API service.
Async invocations and retries are not supported.
In the Tencent Cloud standard environment, only the /tmp directory is readable and writable. When outputting files, please select the /tmp path; otherwise, the service will exit exceptionally due to the lack of write permission.
For projects that requires compression for deployment (JAVA, Go), please make sure that scf_bootstrap is included in the ZIP package.

Request limits

HTTP-triggered functions can be invoked only through API Gateway but not function APIs.
Response headers has the following limits:
The total size of all key and value values cannot exceed 4 KB.
The size of body cannot exceed 6 MB.
When deploying your web service, you must listen on the specified 9000 port and cannot listen on the internal loopback address 127.0.0.1.
Currently, the Connection field in the HTTP request header cannot be customized.

Common Function Request Headers

The common request headers received by your web server from the function environment are as detailed below, none of which can be customized:
Header Field
Description
X-Scf-Request-Id
Current request ID
X-Scf-Memory
Maximum memory that can be used during function instance execution
X-Scf-Timeout
Timeout period for function execution
X-Scf-Version
Function version
X-Scf-Name
Function name
X-Scf-Namespace
Function namespace
X-Scf-Region
Function region
X-Scf-Appid
Appid of function owner
X-Scf-Uin
Uin of function owner

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백