All Products
Search
Document Center

Elastic Container Instance:Overview of image caches

Last Updated:Nov 13, 2024

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.

Feature description

Before you run containers, Elastic Container Instance must pull the specified images. Pulling large images over an unstable network requires an extended period of time when elastic container instances start. To accelerate the creation of elastic container instances, Elastic Container Instance provides the image cache feature. You can create a snapshot based on an image and then use the snapshot 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 based on a Flink image that is approximately 386.26 MB in size on Docker Hub, preparing the image requires 50 seconds. If you use an image cache, preparing the image does not consume time. This significantly reduces the time that is required for starting the instance.

Important

The amount of time saved by using image caches varies based on the number and size of images used by elastic container instances and the network conditions of the image repository.

Methods to create an image cache

An image cache can be manually or automatically created.

Important

We recommend that you use automatically created image caches to save costs. The first time you create an elastic container instance, you must manually create an image cache in advance.

Manually create an image cache

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

image
  • Each time an image cache is created, a snapshot is also created. You must manage manually created image caches.

  • When you manually create an image cache, the system automatically creates a temporary elastic container instance and attaches a temporary performance level-1 (PL1) Enterprise SSD (ESSD) to the temporary instance. The temporary instance provides 2 vCPUs and 4 GiB of memory. The temporary instance pulls specified images to store in the ESSD. Then, the system creates a snapshot of the ESSD. After the image cache is created, the temporary instance and ESSD are automatically released.

  • The instant image cache feature reduces the amount of time required to create an image cache. After you enable this feature, the system enables the instant access feature to create a temporary local snapshot. Then, you can use the local snapshot to create elastic container instances.

    Note

    After the local snapshot is created, the system begins to create a standard snapshot. During the creation of the standard snapshot, you can use the local snapshot to create elastic container instances. After the standard snapshot is created, the system removes the local snapshot. This way, you can use the standard snapshot to create elastic container instances.

  • You can use the image cache reuse feature to accelerate the creation of the image cache. If you enable this feature, the system can automatically match existing image caches when you create an image cache. Duplicate image layers in existing image caches are reused to accelerate the creation of the image cache.

Automatically create an image cache

When you create an elastic container instance, you can enable automatic match of image caches. If no image cache is matched, the system creates a matched image cache during the instance creation. The following figure shows how to automatically create an image cache.

image
  • A snapshot is created each time an image cache is created. Automatically created image caches are managed by Alibaba Cloud.

  • During the creation of the image cache, the system creates a temporary elastic container instance. The temporary instance pulls specified images to store in the temporary storage space of the instance. Then, the system creates a snapshot of the temporary storage space. After the image cache is created, the temporary instance is automatically released.

    Note

    By default, each elastic container instance is assigned a temporary storage space of 30 GiB. If the image that you specify exceeds 30 GiB in size, adjust the size of the temporary storage space.

Comparison

The following table describes the comparison between manually and automatically created image caches.

Item

Manually created image cache

Automatically created image cache

Name

You can specify a name for the instance.

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

Size

The default size is 20 GiB. You can specify another size.

The default size is 30 GiB. If you specify a size for 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 size of the temporary storage space.

Retention period

By default, manually created image caches are permanently retained. You can also configure the retention period in days. Manually created image caches are automatically deleted after their retention periods elapse.

By default, the retention period is managed by Alibaba Cloud.

  • If image caches are never used, the image caches are automatically deleted 7 days after they are created.

  • If image caches are used, the image caches are automatically deleted 30 days after they are last used.

Image cache reuse

You can enable this feature to reuse duplicate image layers on existing image caches. This accelerates the creation of image caches.

Not supported

Instant image cache

You can enable this feature to create a temporary on-premises snapshot and make the image cache instantly available.

Not supported

Quotas

You can view the quota by calling the ListUsage API operation. You can also view the quota by logging on to the 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.

You can view the quota by calling the ListUsage API operation.

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

Elimination policy

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

You can call the CreateImageCache or UpdateImageCache API operation and then set the EliminationStrategy parameter to LRU. This way, the system automatically deletes the least recently used (LRU) image caches when the number of existing image caches reaches the quota limit.

When the number of existing image caches reaches the quota limit, the system automatically deletes the least frequently used image caches based on the LRU rule.

Usage cost

You are charged for manually created image caches and resources created by using the image caches.

You are charged only for resources created by using automatically created image caches.

Methods to use 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 an image cache to create the instance.

Usage method

Description

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. Searches for 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, size, and 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 that has 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 closest to the size of the elastic container instance is assigned the highest priority.

    • Creation time: indicates the time when the image cache was 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 set the image pulling policy to IfNotPresent to prevent repeatedly downloading image layers and affecting the use of the image cache feature.

Specify an image cache

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, you must provide the access credentials including the IP address, username, and password of the repository to which the private image belongs.

    • If the selected image, 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 for elastic container instances.

    • 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 manually created image caches, we recommend that you configure the retention period when you create the image caches to avoid unnecessary snapshot fees. For automatically created image caches, Alibaba Cloud manages the snapshots. You do not need to care for the retention period of the snapshots.

  • After an image cache is created, you can learn about the creation process of the image cache through the creation events of the image cache. The system can retain up to 50 latest creation events.

Billing

Operation phase

Manually created image cache

Automatically created image cache

Create an image cache

Billable items:

  • Temporary resources (the elastic container instance and the disk that are used to create the image cache)

  • The snapshot

Free of charge.

Use the image cache

Billable item: the disk.

If the image cache is greater than 30 GiB in size, you must increase the capacity of the temporary storage space and pay for the additional capacity.

For more information, see Image caches.