All Products
Search
Document Center

Overview of the image cache feature

Last Updated: May 12, 2022

When you create an elastic container instance, you can use the image cache feature to accelerate image pulling and reduce the instance startup period. This topic describes the basic features and billing items of image caches. This topic also describes how to create and use image caches.

Features

When you run containers, Elastic Container Instance must pull the specified images. It can take a long time to pull large images over an unstable network when elastic container instances start. To accelerate the creation of elastic container instances, Elastic Container Instance provides the image cache feature. The image cache feature allows you to create snapshots for the required images and then cache the snapshots before you can use the cached snapshots to create elastic container instances. This prevents or minimizes the downloads of images lays and accelerates the creation of instances.

For example, if you create an elastic container instance from a Flink image that is 386.26 MB in size on Docker Hub, it takes 50 seconds to pull the image. If you cache the image snapshot, it requires only 5 seconds to pull the image.

Note

The amount of time reduced varies based on the number of the images in the image cache, the size of the image used to create the elastic container instance, and the network over which Elastic Container Instance connects to the image repository.

Modes of creating an image cache

An image cache can be manually or automatically created.

  • Manually create an image cache

    You can configure parameters such as the name and size of your image cache based on your business requirements. The following figure shows the procedure of manually creating an image cache.

    Manual image cache
    • A snapshot is created for each image cache. The image cache snapshots that you manually create are managed by yourself.

    • When you manually create an image cache, the system creates a temporary elastic container instance and attaches a temporary performance level-1 (PL1) enhanced SSD (ESSD) to the temporary instance. The temporary instance has two vCPUs and 4 GiB of memory. The temporary ESSD is used to create the image cache snapshot. After the image cache is created, the temporary instance and ESSD are automatically released.

    • The instant image cache feature can be used to reduce the period of creating an image cache. After the instant image cache feature is enabled, the system instantly creates a temporary local snapshot. After the local snapshot is created, you can use the local snapshot to create elastic container instances.

      Note

      After the local snapshot is created, the system starts to create a regular snapshot. While the system is creating the regular snapshot, you can use the local snapshot to create elastic container instances. After the regular snapshot is created, the system deletes the local snapshot and you can use the regular snapshot to create elastic container instances.

    • The image cache reuse feature can be used to accelerate the creation of an image cache. After you enable this feature, the system automatically matches existing image caches when an image cache is created. If existing image caches have duplicate image layers with the image cache that you want to create, the system reuses the duplicate image layers to accelerate the creation of the new image cache.

  • Automatically create an image cache

    You can enable automatic match of image caches when you create an elastic container instance. Then, if no image cache is matched, the system automatically creates an image cache while the system creates the elastic container instance. The following figure shows the procedure of automatically creating an image cache.

    Automatic image cache
    • A snapshot is created for each image cache. The image cache snapshots that the system automatically creates are managed by Alibaba Cloud.

    • When the system automatically creates an image cache, the system creates a temporary elastic container instance and uses the storage space of the instance for the creation of the image cache snapshot. After the system automatically creates the image cache, the temporary instance is automatically released.

      Note

      By default, a temporary elastic container instance has a storage space of 40 GiB, including 20 GiB for the system and 20 GiB for the image cache snapshot. If the image cache that you want to create is no greater than 20 GiB, you do not need to declare additional temporary storage space. If the image cache that you want to create is greater than 20 GiB, you must declare additional temporary storage space.

The following table compares manual image caches with automatic image caches.

Item

Manual image cache

Automatic image cache

Name

You can customize a name.

The system automatically generates a name in the format of auto-create-for-instance ID.

Size

The default value is 20 GiB. You can customize the size.

The default value is 20 GiB. If you declare the size of the temporary storage space when you create the elastic container instance, the size of the image cache = 20 GiB + the size of the temporary storage space.

Retention period

By default, manual image caches are permanently retained. You can also configure the retention period in days. Manual image caches are automatically deleted after their retention periods end.

The retention period is managed by Alibaba Cloud. If an automatic image cache is not used within 30 days after it is created, the system automatically deletes the image cache.

Image cache reuse

You can enable this feature to reuse duplicate image layers of existing image caches and accelerate the creation of an image cache.

This feature is not supported.

Instant image cache

You can enable this feature to create a temporary local snapshot and reduce the period used to create an image cache.

This feature is not supported.

Quota limit

You can view the quota by calling the ListUsage API operation. You can also view the quota by logging on to Elastic Container Instance console and clicking Equity quota in the left-side navigation pane.

If the quota cannot meet your business requirements, submit a ticket to request a quota increase.

The quota is half of the quota for manual image caches and does not consume the quota for manual image caches.

Cost of use

You are charged for the creation and use of manual image caches.

You are charged only for the use, not for the creation of automatic image caches.

Modes of using an image cache

You can use the image cache feature to accelerate the creation of an elastic container instance. If you want to use the image cache feature to create an elastic container instance, you can configure automatic match of image caches or specify the image cache to be used to create the instance.

  • Configure automatic match of image caches

    The system automatically matches the most suitable image cache. The system matches image caches in the following order:

    1. Filters all qualified image caches in the region. The size of each image cache satisfies the size requirements of the temporary storage space of the elastic container instance.

    2. Selects the most suitable image cache based on the match policies. Image caches are matched based on the following attributes in descending order of priority: the match degree, the size, and the creation time of the image cache.

      • Match degree: indicates how an image cache matches the elastic container instance in the image repository and version. The image cache with the highest match degree is assigned the highest priority.

      • Image cache size: indicates the size of the image cache. The image cache whose size is similar to the size of the elastic container instance is assigned the highest priority.

      • Creation time: indicates the time when the image cache is created. The most recently created image cache is assigned the highest priority.

    Note

    If no image cache is matched, the system automatically creates an image cache when the system creates the elastic container instance. Images are pulled when the system creates the instance. We recommend that you configure the image pulling policy to IfNotPresent to prevent repeatedly downloading image layers and affecting the use of the image cache feature.

  • Specify the image cache to be used to create the instance

    Specify the image cache that is to be used to create the elastic container instance. The image cache must be in the Ready state.

Limits

  • A single image cache can contain up to 20 images.

  • To create an image cache, you need to pull container images. Therefore, the creation period of the image cache depends on factors such as the number of the images to be pulled, the size of the image used to create the image cache, and network conditions.

  • When you manually create an image cache, the container image that you specify is used. When the system automatically creates an image cache, the container image that you declare in the elastic container instance is used.

    • If you select a private image, which is not hosted in Alibaba Cloud Container Registry (ACR), you must provide the access credentials including the IP address, username, and password of the repository to which the private image belongs.

    • If the image that you select such as a Docker image needs to be pulled over the Internet, you must configure an elastic IP address (EIP) or a NAT gateway for the elastic container instance. For more information, see Enable Internet access.

    • If the image cannot be pulled due to some reasons such as a timeout error of the remote repository, we recommend that you use ACR to upload the image to an Alibaba Cloud image repository.

  • For manual image caches, we recommend that you configure the retention period when you create the image caches to avoid unnecessary snapshot fees. For automatic image caches, Alibaba Cloud manages the snapshots. You do not need to care for the retention period of the snapshots.

Billing

The billing of image caches involves the creation and use of image caches.

Note

For automatic image caches, you are charged only for the use cost, not for the creation cost.

  • Creation cost of manual image caches

    • Cost of the temporary elastic container instance and ESSD: You are charged for the temporary elastic container instance and ESSD that are generated when you create an image cache.

    • Cost of the snapshot: A snapshot is created for each image cache. You are charged for the retention of the snapshot.

    • Cost for the local snapshot: If the instant image cache feature is enabled, you are charged for the local snapshot that is instantly created for use during the creation of the image cache.

  • Use cost of image caches

    • When you use a manual image cache to create an elastic container instance, the system automatically attaches a disk of the same size as the image cache to the elastic container instance. You are charged for the disk and the elastic container instance.

    • If you declare a temporary storage space when you use an automatic image cache to create an elastic container instance, you are charged for the temporary storage space and the elastic container instance. If you do not declare a temporary storage space, you are charged only for the elastic container instance.

For more information, see Billing.