ECR for container image registry in AWS - Time & Space Complexity
We want to understand how the time to push or pull container images to AWS ECR changes as the number of images grows.
How does the number of images affect the operations needed?
Analyze the time complexity of the following operation sequence.
aws ecr create-repository --repository-name my-app
aws ecr batch-check-layer-availability --repository-name my-app --layer-digests layer1 layer2
aws ecr put-image --repository-name my-app --image-tag v1 --image-manifest file://manifest.json
aws ecr list-images --repository-name my-app
aws ecr batch-delete-image --repository-name my-app --image-ids imageTag=v1
This sequence creates a repository, checks image layers, uploads an image, lists images, and deletes an image in ECR.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Uploading images with
put-imageand checking layers withbatch-check-layer-availability. - How many times: Once per image or image layer during push operations.
As the number of images increases, the number of API calls to upload and check layers grows roughly in proportion.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | About 10 uploads and layer checks |
| 100 | About 100 uploads and layer checks |
| 1000 | About 1000 uploads and layer checks |
Pattern observation: The operations grow linearly as the number of images increases.
Time Complexity: O(n)
This means the time to push or manage images grows directly with the number of images.
[X] Wrong: "Uploading multiple images happens all at once, so time stays the same no matter how many images."
[OK] Correct: Each image requires separate API calls and data transfer, so time increases as images increase.
Understanding how operations scale with input size helps you design efficient cloud workflows and explain your reasoning clearly in interviews.
"What if we batch multiple image uploads in one API call? How would the time complexity change?"