All Products
Search
Document Center

Elastic Container Instance:Overview of image caches

Last Updated:Nov 11, 2022

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

Features

Before 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 layers and accelerates the creation of instances.

For example, if you create an elastic container instance from a Flink image that is about 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.

Creation methods

An image cache can be manually or automatically created.

Note

We recommend that you use automatically-created image caches to save costs. However, if you are creating an elastic container instance for the first time and you want the creation to be as quick as possible, an image cache must be manually created in advance.

  • 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 reduce the time needed to create 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, each elastic container instance is assigned a temporary storage space of 30 GiB for the creation of an image cache. If your image is greater than 30 GiB in size, you need to declare an additional storage capacity for the temporary storage space.

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

Item

Manual creation

Automatic creation

Name

You can specify a name for the instance.

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

Size

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

The default value is 30 GiB. If you declare the storage capacity of the temporary storage space when you create the elastic container instance, the size of the image cache is equal to the sum of 30 GiB and the storage capacity 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 time needed to create an image cache.

This feature is not supported.

Quota

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 Privileges and Quotas 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.

Elimination policy

By default, you can no longer manually create image caches when the number of image caches reaches the quota limit.

You can set the EliminationStrategy parameter of an image cache to LRU by calling the CreateImageCache or UpdateImageCache operation. This way, the system automatically deletes the least recently used (LRU) image caches when the number of image caches reaches the quota limit.

When the number of image caches reaches the quota limit, the system follows the LRU rule to automatically delete the least recently used 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.

Use methods

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 storage capacity 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 you want to use to create the elastic container instance. The image cache must be in the Ready state.

Precautions

  • 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

  • Creation cost of image caches

    • You are charged for snapshots and temporary resources such as elastic container instances and ESSDs when you manually create image caches.

    • You are not charged if the system automatically creates image caches.

  • 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.

    • When you use an automatic image cache to create an elastic container instance, if the image cache is greater than 30 GiB in size, you must declare an additional storage capacity beyond the 30 GiB quota for the temporary storage space and pay for the additional storage capacity. If you do not declare an additional storage capacity, you are charged only for the elastic container instance.

For more information, see Image caches.