0
0
Azurecloud~5 mins

Why network isolation matters in Azure - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why network isolation matters
O(n)
Understanding Time Complexity

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?

Scenario Under Consideration

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.

Identify Repeating Operations

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.
How Execution Grows With Input

Each new subnet adds two operations: one to create the subnet and one to apply security.

Input Size (n)Approx. Api Calls/Operations
101 (vnet) + 10*2 = 21
1001 + 100*2 = 201
2561 + 256*2 = 513

Pattern observation: The total operations grow directly with the number of subnets.

Final Time Complexity

Time Complexity: O(n)

This means the time to isolate the network grows in a straight line as you add more subnets.

Common Mistake

[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.

Interview Connect

Understanding how network isolation scales helps you design cloud setups that stay manageable as they grow.

Self-Check

"What if we applied one shared network security group to all subnets instead of one per subnet? How would the time complexity change?"