Compared with function code packages, container images provide better portability and a more diverse ecosystem of toolchains. However, the irrelevant built-in data contained makes the cold start of an image that is gigabytes in size last several minutes. After the image pull acceleration feature is enabled in Function Compute, the image pull speed can be accelerated by two to five times and the amount of time used to pull images can be reduced from minutes to seconds. This topic describes the principles, usages notes, and configuration methods of image pull acceleration.

How image pull acceleration works

For a function that runs in a custom container, if you enable the image pull acceleration feature when you create or update the function by calling the CreateFunction or UpdateFunction operation, Function Compute assumes a RAM role, pulls the required container image by using a temporary AccessKey pair, and then transfers the image to the image cache service of Function Compute. After the image is cached, the speed for pulling the image is significantly improved.

Usage notes

  • The image pull acceleration feature is supported only in the following regions: China (Beijing), China (Zhangjiakou), China (Hangzhou), China (Shanghai), China (Hong Kong), Singapore (Singapore), US (Silicon Valley), and US (Virginia).
  • If you agree to enable the image pull acceleration feature, you agree to authorize Function Compute to pull images from your repository and transfer them to the image cache service of Function Compute. The image data is encrypted and provided with network isolation and identity authentication to ensure data security. Before you enable this feature, make sure that the operation of transferring images to the image cache service of Function Compute complies with the security regulations and guidelines of your organization.
  • After a function is created or updated, it takes some time to transfer the image. Therefore, cache miss may occur before the cached image is available. The cached image is usually available in 5 minutes after the function is created or updated.

Configuration methods

You can configure image pull acceleration in the following ways when you create or update a function:

Check the availability of image pull acceleration

You can call the GetFunction operation and check the value of the status parameter in the accelerationInfo structure to view the status of image pull acceleration. Valid values of the status parameter:
  • Preparing: Image pull acceleration is being prepared. If you invoke the function now, the image pull speed is not accelerated.
  • Ready: Image pull acceleration is ready. If you invoke the function now, the image pull speed is accelerated.

View image pull acceleration results

Sample project puppeteer-pdf provides a complete example of combining Node.js Express and Puppeteer to convert a web page into a PDF file. Before the image pull acceleration feature is enabled, the process takes 66.51s. After the image pull acceleration feature is enabled, the process takes 15.2s. Performance is improved by 77.1%. The following sample code provides an example on how to check the amounts of time consumed before and after the image pull acceleration feature is enabled:

time curl -H "x-fc-invocation-target: 2016-08-15/proxy/CustomContainerDemo/puppeteer-pdf-no-accl" https://$ACCOUNT_ID.$REGION.fc.aliyuncs.com/generate-pdf\?url\=http://example.com -o /tmp/fc-demo-puppeteer-pdf-no-accl.pdf

# Time spent: 0.06s user 0.09s system 0% cpu 1:06.51 total


time curl -H "x-fc-invocation-target: 2016-08-15/proxy/CustomContainerDemo/puppeteer-pdf-accl" https://$ACCOUNT_ID.$REGION.fc.aliyuncs.com/generate-pdf\?url\=http://example.com -o /tmp/fc-demo-puppeteer-pdf-accl.pdf

# Time spent: 0.05s user 0.06s system 0% cpu 15.200 total