Why network isolation matters in Azure - Performance Analysis
We want to understand how the time to set up network isolation changes as we add more resources.
How does the work grow when isolating more network components?
Analyze the time complexity of creating isolated virtual networks and subnets.
# Create a virtual network
az network vnet create --name MyVnet --resource-group MyGroup --address-prefix 10.0.0.0/16 --location westus
# Create multiple subnets within the virtual network
for i in $(seq 1 $n); do
az network vnet subnet create --address-prefix 10.0.$((i-1)).0/24 --name Subnet$i --vnet-name MyVnet --resource-group MyGroup
done
# Apply network security groups to each subnet
for i in $(seq 1 $n); do
az network nsg create --name NSG$i --resource-group MyGroup --location westus
az network vnet subnet update --name Subnet$i --vnet-name MyVnet --resource-group MyGroup --network-security-group NSG$i
done
This sequence creates one virtual network, then adds multiple subnets and applies security rules to isolate each subnet.
Look at what happens multiple times as we increase subnets.
- Primary operation: Creating subnets and applying network security groups.
- How many times: Once for the virtual network, but once per subnet for subnet creation and security group setup.
Each new subnet adds two operations: one to create the subnet and one to apply security.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 1 (vnet) + 10*2 = 21 |
| 100 | 1 + 100*2 = 201 |
| 256 | 1 + 256*2 = 513 |
Pattern observation: The total operations grow directly with the number of subnets.
Time Complexity: O(n)
This means the time to isolate the network grows in a straight line as you add more subnets.
[X] Wrong: "Adding more subnets won't affect setup time much because they are created together."
[OK] Correct: Each subnet requires separate API calls and security setup, so time grows with each one added.
Understanding how network isolation scales helps you design cloud setups that stay manageable as they grow.
"What if we applied one shared network security group to all subnets instead of one per subnet? How would the time complexity change?"