All Products
Search
Document Center

Elastic Container Instance:Overview of image caches

Last Updated:Mar 08, 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 about 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.

Note

The reduced amount of time due to use of image caches varies based on the number of the images that are used to create the elastic container instance, the sizes of the images, and the network conditions of the image repository.

Methods to create an image cache

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.

    手动imc

    • A snapshot is created every time an image cache is created. Manually created image caches are managed by yourself.

    • During the creation of the 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 provides two 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 makes image caches instantly available. If you enable the feature, 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 accelerate the creation of an image cache. If 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.

    自动imc

    • A snapshot is created every 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 is greater than 30 GiB in size, you must specify an additional size for the temporary storage space.

The following table compares manually created image caches with 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 format of auto-create-for-instance ID.

Size

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

The default value 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 the image caches are never used, they are automatically deleted 7 days after they are created.

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

Image cache reuse

You can enable this feature to reuse image layers that are duplicate on existing image caches and the image cache to be created. This accelerates the creation of the image cache.

Unsupported.

Instant image cache

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

Unsupported.

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.

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

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

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 recently used image caches based on the LRU rule.

Cost of use

You are charged for creation and use of manually created image caches.

You are charged only for use, not for creation of automatically created image caches.

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

  • 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 an image cache 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, 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 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

  • 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 manually created 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 automatically created image cache to create an elastic container instance, if the image cache is greater than 30 GiB in size, you must specify an additional size beyond the 30 GiB quota for the temporary storage space and pay for the additional size. If you do not specify an additional size, you are charged only for the elastic container instance.

For more information about billing of image caches, see Image caches.