Why load balancing matters in Azure - Performance Analysis
Start learning this pattern below
Jump into concepts and practice - no test required
We want to understand how the work done by load balancing changes as more users or requests come in.
How does the system handle growing traffic efficiently?
Analyze the time complexity of distributing incoming requests to backend servers.
// Azure Load Balancer example
resource lb 'Microsoft.Network/loadBalancers@2022-05-01' = {
name: 'myLoadBalancer',
location: resourceGroup().location,
properties: {
frontendIPConfigurations: [
{
name: 'LoadBalancerFrontEnd',
properties: { publicIPAddress: { id: publicIP.id } }
}
],
backendAddressPools: [ { name: 'BackendPool' } ],
loadBalancingRules: [
{
name: 'HTTPRule',
properties: {
frontendIPConfiguration: { id: lb.properties.frontendIPConfigurations[0].id },
backendAddressPool: { id: lb.properties.backendAddressPools[0].id },
protocol: 'Tcp',
frontendPort: 80,
backendPort: 80,
enableFloatingIP: false,
idleTimeoutInMinutes: 4,
loadDistribution: 'Default'
}
}
]
}
}
This setup distributes incoming web requests evenly across multiple servers.
Look at what happens repeatedly as requests come in.
- Primary operation: Routing each incoming request to one backend server.
- How many times: Once per request, no matter how many requests arrive.
Each new request causes one routing decision by the load balancer.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 routing operations |
| 100 | 100 routing operations |
| 1000 | 1000 routing operations |
Pattern observation: The number of routing operations grows directly with the number of requests.
Time Complexity: O(n)
This means the work done by the load balancer grows linearly as more requests come in.
[X] Wrong: "Load balancing handles all requests instantly, so time doesn't grow with more users."
[OK] Correct: Each request still needs to be routed, so the total work grows as requests increase, even if each routing is fast.
Understanding how load balancing scales helps you design systems that stay responsive as more people use them.
"What if the load balancer had to check the health of each backend server before routing every request? How would the time complexity change?"
Practice
Solution
Step 1: Understand load balancing purpose
Load balancing distributes incoming user requests across multiple servers to avoid overload on any single server.Step 2: Identify benefits in Azure context
This distribution keeps applications fast and available, even if one server fails.Final Answer:
It spreads user traffic across servers to keep apps fast and reliable. -> Option CQuick Check:
Load balancing = traffic spread for speed and reliability [OK]
- Confusing load balancing with data storage
- Thinking it updates software automatically
- Assuming it handles backups
Solution
Step 1: Identify Azure Load Balancer requirements
Azure Load Balancer needs a public IP address to receive traffic and a resource group to organize resources.Step 2: Eliminate unrelated options
Virtual machine scale sets, SQL databases, and storage accounts are not mandatory for basic load balancer setup.Final Answer:
A public IP address and a resource group -> Option AQuick Check:
Load balancer setup = public IP + resource group [OK]
- Choosing VM scale set as mandatory
- Confusing with database or storage requirements
- Ignoring the need for a public IP
Solution
Step 1: Understand load balancer health monitoring
Azure Load Balancer checks server health and stops sending traffic to unhealthy servers.Step 2: Predict traffic routing on failure
When one server fails, the load balancer routes all traffic to the healthy server automatically.Final Answer:
Traffic automatically routes only to the healthy server. -> Option DQuick Check:
Load balancer avoids failed servers for traffic [OK]
- Assuming traffic stops completely
- Thinking traffic still goes to failed server
- Believing users see errors immediately
Solution
Step 1: Check load balancer public IP assignment
Without a public IP, the load balancer cannot receive external traffic, causing slow or no responses.Step 2: Review other options
Using many servers or even traffic distribution is normal; health probes improve reliability.Final Answer:
Not assigning a public IP to the load balancer -> Option BQuick Check:
Missing public IP causes traffic issues [OK]
- Blaming too many servers for slowness
- Thinking even traffic distribution causes slow response
- Ignoring the importance of health probes
Solution
Step 1: Identify strategy for high availability
Even traffic distribution with health probes ensures traffic only goes to healthy servers, keeping the app online.Step 2: Evaluate other options
Sending all traffic to one server risks downtime; no health probes means failures go undetected; manual switching is slow and error-prone.Final Answer:
Distribute traffic evenly with health probes to detect failures -> Option AQuick Check:
Even distribution + health probes = high availability [OK]
- Relying on single server for all traffic
- Ignoring health probes in load balancer
- Trying manual traffic switching
