Compared with function code packages, container images provide better portability and benefit from a more diverse toolchain ecosystem. However, container images may contain bloatware. Bloatware causes the image size to exceed one gigabyte, and prolongs the cold start of a container image to several minutes. If the image startup acceleration feature is enabled, the cold start can be accelerated in two phases to increase the startup speed by approximately 90%. The image pull duration is shortened from several minutes to a few seconds. This topic describes how the image startup acceleration feature for Container Registry Enterprise Edition works. This topic also describes how to configure this feature.
- Network isolation is supported. You can configure independent virtual private clouds (VPCs) to implement access control on image repositories. For more information about the message routing feature, see Configure access over VPCs.
- Dedicated bandwidth improves the image pull efficiency.
- The built-in image conversion feature of image repositories prevents cold starts from occurring before a converted image is available in Function Compute. The converted image is an accelerated image.
How it works
You can enable image startup acceleration for a function that runs a custom container and uses a container image in Container Registry Enterprise Edition. When Function Compute processes requests for the function, Function Compute assumes a RAM role and uses a temporary AccessKey pair to pull the accelerated image. This significantly improves the speed of pulling and starting the image.
- The image startup acceleration feature is supported in the following regions: China (Beijing), China (Zhangjiakou), China (Hangzhou), China (Shanghai), China (Shenzhen), China (Hong Kong), Singapore, US (Silicon Valley), US (Virginia), and Japan (Tokyo).
- Function Compute uses the default VPC IP address of your image repository or the IP addresses parsed
by PrivateZone to resolve the domain name of the container image in Container Registry Enterprise
- On the Access Control page of a Container Registry Enterprise Edition instance, the IP address identified by Default Resolution in the Visit IP column is the default resolution IP address of VPC.
- If the Default Resolution identifier does not exist in the Visit IP column on the Access Control page of an ACR Enterprise Edition instance, all IP addresses in the list are parsed by Alibaba Cloud DNS PrivateZone.
- After you create or update a function that uses a container image in Container Registry Enterprise Edition (Basic Edition), you must wait for about five minutes before the accelerated image is generated. Function Compute pulls the accelerated image from your repository when the function is called.
- After you create or update a function that uses a container image in Container Registry Enterprise Edition (Standard Edition) or Container Registry Enterprise Edition (Advanced Edition), Function Compute pulls the accelerated image from your repository when the function is invoked. If the accelerated image is not available in your repository, you must enable the image acceleration feature for the repository to generate an accelerated image. For more information, see Configuration methods.
- Enable image acceleration.
Standard Edition and Advanced Edition instances of Container Registry Enterprise Edition provide the image acceleration feature. You can enable image acceleration when you create or update an image repository. For more information, see Enable image acceleration.
- Select the accelerated image.
When you create or update a function, preferentially use an accelerated image whose name ends with
_acceleratedand enable the image pull acceleration feature. After the function is configured, you can call the accelerated image. This ensures the sustained efficiency of function invocation. You can use one of the following methods to select an accelerated image when you create or update a function:
- Select an accelerated image in the Function Compute console. For more information, see Create a function.
- Select an accelerated image by using Serverless Devs. For more information, see YAML syntax.
customContainerConfig: image: registry-vpc.<regionId>.aliyuncs.com/fc-demo/python-flask:[Image version_accelerated]
- Select an accelerated image by using the SDK. For more information, see Create a custom container function.