How to check image download time in ECS?

Viewed 298

I want to monitor the image download time when a new deployment is ran. I saw that the task event details in the ECS console can give me a rough estimate, but I cannot really tell if the time consumed is image download time or something else. I would also like to know if it's using the cached image or from the remote repository. Is there a way to do this? Please help

1 Answers

But I cannot really tell if the time consumed is image download time or something else

Not sure if you can calculate the image pull time from AWS ECS events as I did not find this in ECS event, but one of the simplest approaches that you can try is to pull image manual on your ECS instance that will give some better estimate by using time with docker pull.

time docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
Digest: sha256:185518070891758909c9f839cf4ca393ee977ac378609f700f60a771a2dfe321
Status: Image is up to date for alpine:latest

real    0m5.789s
user    0m0.033s
sys 0m0.039s

I would also like to know if it's using the cached image or from the remote repository. Is there a way to do this?

You can control this behaviour using ECS_IMAGE_PULL_BEHAVIOR this ECS variable, as by default it will pull image each time, so you can use prefer-cached if you want to improve launch time.

ECS_IMAGE_PULL_BEHAVIOR

Example values: default | always | once | prefer-cached

Default value on Linux: default

Default value on Windows: default

The behavior used to customize the pull image process for your container instances. The following describes the optional behaviors:

If default is specified, the image is pulled remotely. If the image pull fails, then the container uses the cached image on the instance.

If always is specified, the image is always pulled remotely. If the image pull fails, then the task fails. This option ensures that the latest version of the image is always pulled. Any cached images are ignored and are subject to the automated image cleanup process.

If once is specified, the image is pulled remotely only if it has not been pulled by a previous task on the same container instance or if the cached image was removed by the automated image cleanup process. Otherwise, the cached image on the instance is used. This ensures that no unnecessary image pulls are attempted.

If prefer-cached is specified, the image is pulled remotely if there is no cached image. Otherwise, the cached image on the instance is used. Automated image cleanup is disabled for the container to ensure that the cached image is not removed.

ecs-agent-config

amazon-ecs-adds-options-to-speed-up-container-launch-times

Related