0
0
Azurecloud~5 mins

High availability design patterns in Azure - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: High availability design patterns
O(n)
Understanding Time Complexity

We want to understand how the effort to keep a system always running grows as we add more components or users.

How does the work needed to maintain high availability change when the system grows?

Scenario Under Consideration

Analyze the time complexity of deploying multiple instances with load balancing and failover.

// Create a load balancer
resource lb 'Microsoft.Network/loadBalancers@2022-05-01' = {
  name: 'myLoadBalancer'
  location: resourceGroup().location
  properties: {
    frontendIPConfigurations: [...],
    backendAddressPools: [...]
  }
}

// Deploy multiple VM instances
var vmCount = 5
resource vms 'Microsoft.Compute/virtualMachines@2022-08-01' = [for (i, int) in range(0, vmCount): {
  name: 'vm${i}'
  location: resourceGroup().location
  properties: { ... }
}]

// Attach VMs to load balancer backend pool
// Setup health probes and failover rules

This sequence sets up a load balancer and multiple virtual machines to share traffic and provide failover.

Identify Repeating Operations

Look at what happens multiple times as we add more VMs.

  • Primary operation: Creating each virtual machine instance.
  • How many times: Once per VM, so equal to the number of VMs.
  • Supporting operations: Attaching each VM to the load balancer backend pool also repeats per VM.
How Execution Grows With Input

As you add more VMs, the number of creation and attachment steps grows directly with the number of VMs.

Input Size (n)Approx. Api Calls/Operations
10About 10 VM creations + 10 attachments
100About 100 VM creations + 100 attachments
1000About 1000 VM creations + 1000 attachments

Pattern observation: The work grows in a straight line with the number of VMs added.

Final Time Complexity

Time Complexity: O(n)

This means the time to set up high availability grows directly with how many instances you add.

Common Mistake

[X] Wrong: "Adding more VMs won't increase setup time because the load balancer handles them all at once."

[OK] Correct: Each VM still needs to be created and connected individually, so the total work grows with the number of VMs.

Interview Connect

Understanding how setup effort grows helps you design systems that stay reliable as they grow, a key skill in cloud architecture.

Self-Check

"What if we used a managed service that automatically scales instances? How would the time complexity change?"