ACR image building and pushing in Azure - Time & Space Complexity
When building and pushing container images to Azure Container Registry (ACR), it's important to understand how the time taken grows as the number of images or layers increases.
We want to know how the number of build and push operations changes as we add more images.
Analyze the time complexity of the following operation sequence.
az acr build --registry myRegistry --image myapp:v1 .
az acr build --registry myRegistry --image myapp:v2 .
az acr build --registry myRegistry --image myapp:v3 .
// Repeat for n images
This sequence builds and pushes multiple container images one by one to ACR.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Each
az acr buildcommand triggers a build and push operation to ACR. - How many times: This operation repeats once for each image, so n times for n images.
As the number of images increases, the total build and push operations increase proportionally.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 build and push operations |
| 100 | 100 build and push operations |
| 1000 | 1000 build and push operations |
Pattern observation: The number of operations grows linearly with the number of images.
Time Complexity: O(n)
This means the total time grows directly in proportion to the number of images you build and push.
[X] Wrong: "Building multiple images at once takes the same time as building one image."
[OK] Correct: Each image requires its own build and push process, so time adds up with more images.
Understanding how build and push operations scale helps you design efficient deployment pipelines and manage cloud resources wisely.
What if we used a multi-stage build to combine images? How would the time complexity change?