Route tables configuration in AWS - Time & Space Complexity
When setting up route tables in AWS, it is important to understand how the time to configure grows as you add more routes.
We want to know how the number of routes affects the time it takes to apply changes.
Analyze the time complexity of the following operation sequence.
# Create a route table
aws ec2 create-route-table --vpc-id vpc-12345678
# Add multiple routes
aws ec2 create-route --route-table-id rtb-12345678 --destination-cidr-block 10.0.1.0/24 --gateway-id igw-12345678
aws ec2 create-route --route-table-id rtb-12345678 --destination-cidr-block 10.0.2.0/24 --gateway-id igw-12345678
# ... repeated for each route
This sequence creates a route table and then adds several routes to it, one at a time.
- Primary operation: Adding a route with
create-routeAPI call. - How many times: Once for each route you add to the route table.
Each new route requires a separate API call to add it. So, if you add more routes, the total calls increase directly with the number of routes.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 calls to add routes |
| 100 | 100 calls to add routes |
| 1000 | 1000 calls to add routes |
Pattern observation: The number of API calls grows directly with the number of routes added.
Time Complexity: O(n)
This means the time to configure route tables grows linearly with the number of routes you add.
[X] Wrong: "Adding multiple routes happens all at once in a single API call."
[OK] Correct: Each route requires its own API call, so the total time grows with how many routes you add.
Understanding how route table configuration scales helps you design efficient cloud networks and shows you can think about how infrastructure changes grow with size.
"What if AWS allowed adding multiple routes in a single API call? How would the time complexity change?"