Why VPC provides network isolation in AWS - Performance Analysis
We want to understand how the work needed to isolate networks in a VPC changes as the network size grows.
Specifically, how does adding more resources affect the isolation process?
Analyze the time complexity of creating network isolation using VPC components.
// Create a VPC
aws ec2 create-vpc --cidr-block 10.0.0.0/16
// Create subnets inside the VPC
aws ec2 create-subnet --vpc-id vpc-1234 --cidr-block 10.0.1.0/24
aws ec2 create-subnet --vpc-id vpc-1234 --cidr-block 10.0.2.0/24
// Create security groups
aws ec2 create-security-group --group-name sg1 --vpc-id vpc-1234
aws ec2 create-security-group --group-name sg2 --vpc-id vpc-1234
// Add rules to security groups
aws ec2 authorize-security-group-ingress --group-id sg-1234 --protocol tcp --port 22 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-id sg-5678 --protocol tcp --port 80 --cidr 10.0.1.0/24
This sequence sets up a VPC with subnets and security groups to isolate network traffic.
Look at what actions repeat as the network grows.
- Primary operation: Creating subnets and security group rules.
- How many times: Once per subnet and once per security group rule added.
As you add more subnets and security group rules, the number of API calls grows with each addition.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 subnets + rules | About 20 calls (10 subnet creations + 10 rule additions) |
| 100 subnets + rules | About 200 calls |
| 1000 subnets + rules | About 2000 calls |
Pattern observation: The work grows directly with the number of subnets and rules added.
Time Complexity: O(n)
This means the time to set up network isolation grows in a straight line as you add more network parts.
[X] Wrong: "Adding more subnets or rules won't affect setup time much because the VPC handles isolation automatically."
[OK] Correct: Each subnet and rule requires separate setup calls, so more parts mean more work and time.
Understanding how network isolation scales helps you design cloud networks that stay manageable as they grow.
"What if we used fewer security group rules but more subnets? How would the time complexity change?"