Artifact Registry creation in GCP - Time & Space Complexity
When creating Artifact Registries in Google Cloud, it is important to understand how the time to complete the process changes as you create more registries.
We want to know how the number of registries affects the total time and operations needed.
Analyze the time complexity of the following operation sequence.
// Create multiple Artifact Registries
for (let i = 0; i < n; i++) {
gcloud artifacts repositories create repo-" + i + " \
--repository-format=docker \
--location=us-central1
}
This sequence creates n separate Artifact Registries, each with the same format and location.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Artifact Registry creation API call for each repository.
- How many times: Exactly n times, once per repository.
Each new registry requires a separate creation call, so the total operations grow directly with the number of registries.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 creation calls |
| 100 | 100 creation calls |
| 1000 | 1000 creation calls |
Pattern observation: The number of operations increases in a straight line as n grows.
Time Complexity: O(n)
This means the time and operations needed grow directly in proportion to the number of Artifact Registries you create.
[X] Wrong: "Creating multiple registries happens all at once, so time stays the same no matter how many."
[OK] Correct: Each registry creation is a separate call and resource setup, so more registries mean more total work and time.
Understanding how operations scale with input size shows you can think about cloud resource management efficiently, a useful skill in real projects and interviews.
"What if we created all registries in parallel instead of sequentially? How would the time complexity change?"