GCP global infrastructure (regions, zones) - Time & Space Complexity
When working with GCP's global infrastructure, it's important to understand how operations scale as you use more regions and zones.
We want to know how the number of infrastructure calls grows when managing multiple regions and zones.
Analyze the time complexity of listing all zones in all regions.
// Pseudocode for listing zones in all regions
regions = gcp.listRegions()
for region in regions {
zones = gcp.listZones(region)
process(zones)
}
This sequence fetches all regions, then for each region fetches its zones.
Look at the calls that happen multiple times.
- Primary operation: API call to list zones per region.
- How many times: Once per region.
As the number of regions grows, the number of zone-listing calls grows too.
| Input Size (n = regions) | Approx. API Calls |
|---|---|
| 10 | 1 (listRegions) + 10 (listZones) = 11 |
| 100 | 1 + 100 = 101 |
| 1000 | 1 + 1000 = 1001 |
Pattern observation: The number of API calls grows roughly in direct proportion to the number of regions.
Time Complexity: O(n)
This means the total calls grow linearly as you add more regions.
[X] Wrong: "Listing zones is a single call regardless of regions."
[OK] Correct: Each region has its own zones, so you must call the API once per region, not just once total.
Understanding how cloud infrastructure calls scale helps you design efficient systems and shows you grasp real-world cloud operations.
"What if zones were listed globally in a single call instead of per region? How would the time complexity change?"