Data plane security
When communicating with users, Function Compute encrypts invocation requests and responses by using Transport Layer Security (TLS) 1.2 or later. Internal communications use proprietary protocols to prevent information leakage and tampering. This topic describes the data plane security protections module by module.
Security of the access service
In the internal data plane workflow, the access service is mainly responsible for function invocations. As the entry point for function invocations, the access service uses Server Load Balancer (SLB) to implement load balancing and network security protection.
By default, functions are accessible only over the Internet. You can configure a function to be accessible only from a specific virtual private cloud (VPC). The two access modes are mutually exclusive.
By invocation mode, function invocations are classified into synchronous invocations, asynchronous invocations, and asynchronous tasks:
-
Synchronous invocations: Use the request-response mode. Invocation request details are not cached, and the system does not retry failed invocations caused by function execution errors.
-
Asynchronous invocations: After an invocation request is received, the request is cached to Simple Message Queue (formerly MNS), and a response is returned immediately after the request is cached. Then Function Compute asynchronously retrieves requests from Simple Message Queue (formerly MNS) for execution, and Function Compute guarantees that each request is executed at least once.
-
The Simple Message Queue (formerly MNS) queues used by different users are isolated at least at the account level. For functions with high invocation volumes, you can use function-level isolation.
-
If an invocation fails, Function Compute retries the function execution error up to 3 times by default. For other errors such as throttling and system errors, retries use binary exponential backoff. You can configure the number of retries and the maximum message time to live (TTL).
-
After an asynchronous invocation is complete, Function Compute supports configuring the result callback feature. You can use the result callback to save invocation events and verify invocation results.
-
-
Asynchronous tasks: Compared with asynchronous invocations, asynchronous tasks provide richer task control and observability capabilities. You can choose to terminate an asynchronous task. For more information, see Asynchronous tasks.
Security of the scheduling service
The scheduling service manages compute node lifecycles, function instance lifecycles, and invocation routing.
Compute nodes
Function Compute uses a combination of ECS Bare Metal Instances and ECS instances as compute nodes, which enables user-level dynamic migration.
By default, the scheduling service provides each user with compute nodes equivalent to a total of 50–600 CPU logical cores and 100–1,200 GB of memory. Resource pooling provides burst capacity equal to half of these cores and memory. When the resource pool is exhausted, the scheduling service scales out for the user at a rate not exceeding 360 cores per minute. If the scale-out rate is exceeded, a throttling error occurs. For more information, see Compute node limits for a single account in each region.
The maximum validity period of a compute node does not exceed 120 hours. When the scheduling service detects an exception on a compute node, it reconstructs the compute node in advance.
Function instances
Function instances are either on-demand or provisioned:
-
On-demand instances: Dynamically created in response to function invocations. During light hibernation (formerly idle), an instance may be retained for a period of time, but the retention duration is not guaranteed and does not exceed 5 minutes. The platform may reclaim the instance in advance.
-
Provisioned instances: Created based on the initial instance count and automatic scaling policies that you configure. Instances are not released during light hibernation (formerly idle).
By default, the scheduling service provides each user with a burst capacity of 300 function instances. When this limit is exceeded, the service scales out for the user at a rate not exceeding 300 instances per minute. If the scale-out rate is exceeded, a throttling error occurs. To apply for a higher burst capacity limit on function instances, join the DingTalk user group (group ID 64970014484).
Function instances have a maximum validity period of 36 hours. An instance is reconstructed when:
-
Function code or instance configuration is modified
-
The function execution times out
-
Memory usage exceeds the configured limit
-
The client terminates the function execution
-
The scheduling service initiates reconstruction for load balancing
Routing
The scheduling service routes invocations using the bin-pack algorithm. A single function instance may handle multiple invocation requests, and requests from the same client may be dispatched to different instances. Do not assume that global variables or file state are shared — or isolated — across invocations.
The scheduling service enforces the function timeout period you configure. When a timeout expires, the function instance is reclaimed.
Security of compute nodes
Compute nodes execute user function code. Function Compute uses two types of compute nodes: ECS Bare Metal Instances and ECS instances, as shown in the following figure. This section describes the security measures at each layer from the outside in.
Alibaba Cloud infrastructure protections
Compute nodes provide the following standard Alibaba Cloud security protection capabilities. For more information, see the Alibaba Cloud Security Whitepaper.
-
Multi-zone disaster recovery: Compute nodes in a region are distributed across multiple zones to support cross-zone failover.
-
Isolated VPC environment: Compute nodes reside in an isolated VPC environment, and users cannot directly access compute nodes.
-
Cloud Shield security protection: Function Compute nodes use the Alibaba Cloud Cloud Shield service to provide vulnerability detection, security defense, and quick response to and handling of intrusions.
-
Vulnerability fixing or security update: Function Compute is responsible for fixing vulnerabilities and performing security updates on compute nodes. The update process is transparent to users.
User-level and function-level isolation
Virtualization-based isolation
ECS Bare Metal Instances can host function instances from different users. Alibaba Cloud Sandboxed-Container provides function-level virtualization and container isolation. ECS instances host only function instances from the same user, and provide user-level virtualization isolation by relying on ECS isolation. Function-level container isolation is implemented by using container technologies such as runC.
Network isolation
A function instance is configured with a private IP address, so users cannot directly access it, and instances cannot reach each other over the network. Network isolation is implemented by using Open vSwitch, iptables, and routing tables.
Users can configure one of the following 4 modes for external network access:
| Mode | Description |
|---|---|
| Internet only (default) | Function instances access only the Internet. This is the default mode. |
| VPC only | Function instances access only the configured VPC network, such as the private IP addresses of ApsaraDB RDS, File Storage NAS, and ECS instances, but not the Internet |
| Internet and VPC | Function instances access both the Internet and a specified VPC |
| No access | Function instances have no permission to access any external network |
Resource limits
CPU capacity is allocated proportionally to the configured memory size. During a cold start, additional CPU resources are allocated for up to 20 seconds to reduce startup time.
| Resource | Standard instance | Performance instance |
|---|---|---|
| File system capacity | 512 MB | Up to 10 GB |
| Network bandwidth | 1 Gbit/s | Up to 5 Gbit/s |
Idle instance freezing
When a function instance is not processing requests, it is frozen. The instance is unfrozen before the next request is processed.
Instance login for troubleshooting
Authenticated users can log on to their function instances to locate issues in the production environment.
Vulnerability fixing and security updates
Function Compute is responsible for fixing vulnerabilities and performing security updates on the sandbox containers of function instances. The update process is transparent to users.
Security capabilities of runtime environments
Temporary identity credentials
Function Compute requests temporary identity credentials for the execution role that you configure. These credentials are injected into the runtime environment by using environment variables, and are passed to user code through input parameters during invocation. Users can use the temporary identity credentials to access external Alibaba Cloud services.
Function execution error collection
Runtime environments collect function execution errors and logs to help you diagnose issues.
Lifecycle hooks
Runtime environments provide the Initializer hook and PreStop hook to extend security capabilities based on your requirements.
Non-persistent storage
The file system and memory of a runtime environment are released when the function instance is released. Data is not persisted to local storage. For persistent storage, configure Alibaba Cloud File Storage NAS, or persist data to Object Storage Service (OSS).
Immutable code and layers
Changes to the code directory /code and the layer directory /opt apply only to the current function instance. They do not affect the code or libraries of other function instances handling invocations for the same function.
Vulnerability fixing and runtime updates
Vulnerability fixes and library updates are performed for runtime environments. If a change affects user compatibility, users are notified in advance by using internal messages, text messages, or other methods.
For custom runtimes or custom container images, you are responsible for ensuring the security of the runtime environment.
In addition, for compiled languages such as Java, C#, and Go, fixing security vulnerabilities in the SDKs provided by Function Compute requires you to update the dependencies, recompile the code, and upload the package.
Runtime version lifecycle
The community defines explicit support periods for runtime environment versions. For a runtime version that the community no longer supports, Function Compute announces the end of the support period accordingly, and stops supporting the version in the following order:
-
New functions cannot use the runtime version.
-
Existing functions cannot be modified.
-
Function execution is prohibited.
Function Compute does not guarantee that a runtime version whose support has stopped can always be executed normally.