VPN Gateway for hybrid connectivity in Azure - Time & Space Complexity
When setting up a VPN Gateway for hybrid connectivity, it is important to understand how the time to establish and maintain connections changes as the number of sites grows.
We want to know how the work involved grows when more networks connect through the VPN Gateway.
Analyze the time complexity of the following operation sequence.
// Create a VPN Gateway
az network vnet-gateway create --resource-group MyResourceGroup --name MyVpnGateway --vnet MyVnet --public-ip-address MyPublicIP --gateway-type Vpn --vpn-type RouteBased --sku VpnGw1 --no-wait
// Create connections to multiple on-premises sites
for site in sites:
az network vpn-connection create --resource-group MyResourceGroup --name ConnectionToSite --vnet-gateway1 MyVpnGateway --local-gateway2 site.localGateway --shared-key "abc123"
This sequence creates one VPN Gateway and then sets up connections to multiple on-premises sites for hybrid network connectivity.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Creating VPN connections to each on-premises site.
- How many times: Once per site, so the number of connections equals the number of sites.
Each new site requires a separate VPN connection to be created and managed.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 connection creations |
| 100 | 100 connection creations |
| 1000 | 1000 connection creations |
Pattern observation: The number of operations grows directly with the number of sites added.
Time Complexity: O(n)
This means the time to set up VPN connections grows linearly as you add more sites.
[X] Wrong: "Adding more sites won't increase setup time much because the VPN Gateway handles all connections at once."
[OK] Correct: Each site requires its own connection setup, so the total work increases with each new site.
Understanding how connection setup scales helps you design networks that grow smoothly and predict how long deployments will take.
"What if we used a single VPN connection with multiple tunnels instead of one connection per site? How would the time complexity change?"