Default VPC and subnets in GCP - Time & Space Complexity
When creating a default VPC in Google Cloud, several subnets are automatically set up. We want to understand how the time to create these resources changes as the number of regions grows.
How does the work grow when more subnets are created across regions?
Analyze the time complexity of the following operation sequence.
# Create a default VPC network
gcloud compute networks create default --subnet-mode=auto
# Automatically creates one subnet per region
# Each subnet has a predefined IP range
# List all subnets in the default VPC
gcloud compute networks subnets list --filter="network=default"
This sequence creates a default VPC with one subnet in each region and lists them.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Creating one subnet per region.
- How many times: Once for each region where Google Cloud has a data center.
Each new region adds one subnet creation operation. So, if the number of regions doubles, the number of subnet creations doubles too.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 regions | 10 subnet creations |
| 100 regions | 100 subnet creations |
| 1000 regions | 1000 subnet creations |
Pattern observation: The number of operations grows directly with the number of regions.
Time Complexity: O(n)
This means the time to create the default VPC and its subnets grows linearly with the number of regions.
[X] Wrong: "Creating the default VPC is a single operation that takes the same time no matter how many regions exist."
[OK] Correct: Each region requires a separate subnet to be created, so more regions mean more work and more time.
Understanding how resource creation scales helps you design cloud infrastructure that grows smoothly. This skill shows you can think about costs and delays as systems get bigger.
"What if the default VPC used a single global subnet instead of one per region? How would the time complexity change?"