Recommend a Load-Balancing and Routing Solution — Lesson
AZ-305 › Unit 4: Design infrastructure solutions › Design network solutions › Recommend a load-balancing and routing solution
Recommend a Load-Balancing and Routing Solution — Lesson
A large global retailer's checkout API runs across three Azure regions. The team's first deployment uses one regional Application Gateway per region fronted by Azure Traffic Manager (DNS-based) for global routing across the three regions. A regional outage takes roughly 4 minutes for traffic to fail over — long enough for thousands of users to retry, abandon, and complain on social media. The architect replaces Traffic Manager with Azure Front Door Premium using AnyCast at the global edge: the same regional App Gateways remain behind it, but global edge routing decisions now happen at the network layer rather than via DNS TTL caching. Regional failover now completes within seconds rather than minutes, and the customer complaints subside immediately. This lesson is about choosing the right load-balancing layer for each scope — L4 regional, L7 regional, L7 global, DNS global — and combining them in a layered stack so traffic always finds a healthy endpoint quickly, without operator intervention.
We will work through Azure's load-balancing story the way the AZ-305 exam expects you to: distinguish Azure Load Balancer (L4 regional, TCP/UDP) from Application Gateway (L7 regional with WAF) from Front Door (global L7 AnyCast) from Traffic Manager (DNS-level global routing), and pick the right combination for each workload. Reference: the AZ-305 exam study guide, particularly Chapter 4 Skill $4.4 on load-balancing, plus Microsoft Learn's load-balancing decision tree.
Why This Matters
Load balancing is where availability becomes user-experience and the difference between an invisible regional failover and a customer-visible outage. A correctly chosen load balancer survives backend failures invisibly to end users; a wrongly chosen one converts a one-instance failure into a customer-visible outage on social media within minutes. The AZ-305 exam tests this LO heavily because the four Azure load balancers serve overlapping but distinct purposes — and architects routinely mix them up, choosing Traffic Manager when Front Door would deliver faster failover, or App Gateway when a simple Standard LB would suffice.
The career payoff is concrete: every "how do we route global traffic?" workshop, every "this single VM is a bottleneck" review, every multi-region failover design, every WAF placement debate touches this LO at the architectural level.
Prerequisites
- L4 vs L7. Can you describe the difference? — Self-check: which can route by URL path?
- DNS vs IP-level routing. Are you familiar with the trade-off? — Self-check: which has a TTL that delays failover?
- Health probes. Do you know how each LB checks backend health? — Self-check: what's the typical interval?
- TLS termination. Can you describe where TLS terminates in each LB? — Self-check: which one passes TLS through end-to-end?
- Session affinity. Have you used it? — Self-check: what cookie does App Gateway add?
If any of these feels shaky, pause and review LO-26 (HA for compute), LO-45 (internet connectivity), and LO-47 (network performance) before continuing this lesson.
Learning Objectives
- Analyse a load-balancing requirement (scope, layer, latency, routing rules, failover budget) and translate it to the right Azure service.
- Evaluate trade-offs between
Azure Load Balancer,Application Gateway,Front Door, andTraffic Manager, including cost and failover speed. - Recommend a global routing strategy choosing between AnyCast (Front Door) and DNS-level (Traffic Manager) based on failover-speed requirements.
- Design a layered load-balancing stack (global regional L7 L4 backend instances) that survives any single-region or single-zone failure.
- Configure session affinity, health probes, TLS termination, and WAF policies correctly per service tier.
- Recognise anti-patterns — Traffic Manager for fast failover on HTTP workloads, Basic LB still in production after retirement, missing or unhealthy health probes — and rewrite each one.
Building Blocks
Azure Load Balancer — L4 regional traffic distribution. Formally, Microsoft.Network/loadBalancers Basic / Standard SKU; Standard offers 99.99% SLA, zone-redundant or zonal frontends, HA Ports. Pure TCP/UDP. It matters as the foundation for VMSS and AKS internal load balancing.
Application Gateway — L7 regional load balancer with WAF, URL-based routing, TLS termination, session affinity. Formally, Microsoft.Network/applicationGateways v2 (Standard or WAF). 99.95% SLA zone-redundant. It matters for path-based routing inside a region, e.g., /api APIs, /web web app.
Azure Front Door — Global L7 AnyCast edge. Tiers: Standard / Premium / classic (retiring). 99.99% SLA. Includes WAF, caching, DDoS Protection. It matters because Front Door is the modern global-routing default — fast failover, AnyCast at edge.
Azure Traffic Manager — DNS-based global routing. Returns different DNS responses based on policy (performance, priority, weighted, geographic). 99.99% SLA on DNS resolution. It matters for non-HTTP workloads or where DNS-based routing is preferred (e.g., for services not behind HTTP).
Health probe — A periodic check the LB uses to determine backend health. Each LB has its own probe model. It matters because health probes drive failover timing and correctness.
Session affinity (sticky sessions) — A way to bind a user's session to one backend. L4 LB: source-IP affinity. L7 App Gateway: cookie-based. Front Door: cookie-based. It matters for stateful apps that store session data on the backend.
Backend pool — The set of targets behind the LB. Can be VMs (LB, App Gateway), App Services (App Gateway, Front Door), or IP addresses (App Gateway, Front Door). It matters because pool composition determines what the LB can route to.
TLS passthrough vs termination — Whether the LB terminates TLS or passes it through encrypted. App Gateway / Front Door terminate (decrypt, optionally re-encrypt to backend). Standard LB passes through unchanged. It matters for end-to-end encryption requirements.
HA Ports — A Standard LB feature that load-balances all ports / protocols to a single rule. Useful for NVAs and firewalls. It matters when balancing a single appliance fleet handling many protocols.
Deep Dive
1. The four load balancers — scope and layer
| Service | Scope | Layer | Best for |
|---|---|---|---|
Load Balancer | Regional | L4 (TCP/UDP) | Internal LB for VMSS, AKS internal, NVA pools |
Application Gateway | Regional | L7 (HTTP) | Internal L7 with WAF, path-based routing |
Front Door | Global | L7 (HTTP) AnyCast | Global public HTTP services |
Traffic Manager | Global | DNS | Non-HTTP global; legacy fallback |
[!TIP] Default rule of thumb: HTTP traffic, default to Front Door (global) or Application Gateway (regional). Non-HTTP traffic, default to Load Balancer (L4). Traffic Manager fills the gap when DNS-level routing for non-HTTP is needed.
2. Standard LB vs Basic — Basic retiring
| Property | Basic LB | Standard LB |
|---|---|---|
| SLA | None | 99.99% (with zone redundancy) |
| Zone-redundant frontend | No | Yes |
| HA Ports | No | Yes |
| Outbound rules | Implicit | Explicit |
| Secure-by-default | No | Yes (deny inbound) |
| Status | Retiring September 2025 | Current default |
Production must use Standard. Migration tools exist; plan ahead of the retirement date.
3. Application Gateway features — L7 inside the region
resource appgw 'Microsoft.Network/applicationGateways@2024-03-01' = {
name: 'appgw-prod'
location: location
zones: ['1','2','3']
properties: {
sku: { name: 'WAF_v2', tier: 'WAF_v2' }
autoscaleConfiguration: { minCapacity: 2, maxCapacity: 10 }
backendAddressPools: [ { name: 'web', properties: { backendAddresses: [ { fqdn: 'web-app.privatelink.azurewebsites.net' } ] } } ]
httpListeners: [ { name: 'http', properties: { frontendIPConfiguration: { id: feIpId }, frontendPort: { id: fePortId }, protocol: 'Https', sslCertificate: { id: certId } } } ]
requestRoutingRules: [ { name: 'web', properties: { ruleType: 'PathBasedRouting', urlPathMap: { id: pathMapId }, httpListener: { id: listenerId } } } ]
}
}| Feature | Use |
|---|---|
| URL path-based routing | /api API pool; /web web pool |
| Host header routing | Multi-tenant: tenant1.example.com pool1 |
| Session affinity | Cookie-based (ARRAffinity) |
| End-to-end TLS | Decrypt at AppGW, re-encrypt to backend |
| WAF | Premium feature; OWASP CRS rules |
| Autoscale | Min / max capacity units; scale on demand |
| Zone redundancy | Available with v2 SKU |
4. Front Door — global AnyCast L7
Front Door routes via AnyCast at network layer — failover is near-instant on health probe failure. Compare to Traffic Manager (DNS), where failover waits for client cache to expire.
| Feature | Standard | Premium |
|---|---|---|
| AnyCast at POPs | Yes | Yes |
| WAF | Limited managed rules | OWASP + custom + bot management |
| Private Link to origins | No | Yes |
| Microsoft-managed rule set | Limited | Full |
| Best for | Smaller public HTTP | Tier-1 public HTTP |
5. Traffic Manager — DNS routing
| Routing method | Use |
|---|---|
| Priority | Failover (primary secondary) |
| Performance | Nearest region by latency |
| Weighted | A/B / canary by percentage |
| Geographic | Compliance — route by user location |
| MultiValue | Multiple A records returned (client-side LB) |
| Subnet | Route by client subnet (B2B) |
[!WARNING] Traffic Manager failover is bounded by DNS TTL + client DNS cache. Default TTL is 60 s; some clients ignore short TTLs entirely. For fast failover, use Front Door instead.
6. Combining services — layered architecture
Most enterprise stacks layer multiple LBs:
Each layer adds value: Front Door global edge; AppGW regional WAF + path routing; Standard LB cheap L4 distribution to compute. Smaller stacks collapse layers (e.g., Front Door directly to App Service).
// Compare end-to-end latency across LB layers
ApplicationGatewayAccessLog
| where TimeGenerated > ago(1h)
| summarize avgLatency = avg(timeTaken_d), p95 = percentile(timeTaken_d, 95) by bin(TimeGenerated, 5m)
| order by TimeGenerated desc7. Health probes — the silent reliability layer
Each LB probes backends differently:
| LB | Probe protocol | Typical interval |
|---|---|---|
| Standard LB | TCP / HTTP / HTTPS | 5 s |
| Application Gateway | HTTP / HTTPS | 30 s (default; configurable) |
| Front Door | HTTP / HTTPS from each POP | 30 s |
| Traffic Manager | HTTP / HTTPS | 30 s |
Failover speed = probe interval × failure threshold + time-to-evict. Front Door's distributed probes from each POP give the fastest realistic failover.
8. Cost considerations
Approximate cost shape:
| Service | Cost basis |
|---|---|
| Standard LB | Rule-based + data processed |
| Application Gateway v2 | Capacity-unit-hour + data processed |
| Application Gateway WAF v2 | premium over Standard v2 |
| Front Door Standard | Per request + base hourly |
| Front Door Premium | Standard; includes WAF |
| Traffic Manager | Per DNS query (cheap) |
9. Cross-region active-active vs active-passive
Multi-region designs come in two flavours:
| Pattern | Description | Pros | Cons |
|---|---|---|---|
| Active-active | All regions serve traffic simultaneously | Lowest latency, no failover delay | Stateful data needs multi-write or sharding |
| Active-passive | One region serves; others standby | Simpler state management | Failover delay; cold compute waste |
Front Door supports both via priority + weighted routing. For tier-1 services where every customer's traffic should land in the nearest region, active-active wins; for compliance-driven workloads with strict data residency, active-passive may be required.
[!TIP] Active-active works well for stateless tiers and Cosmos DB / GZRS / Azure SQL Failover Group backends. Active-passive is the right starting point for SQL workloads that aren't yet multi-write-ready.
10. Combining Front Door and Application Gateway
Front Door at the edge can route directly to backend pools (App Service, Storage, custom origins), but the most-defensible pattern for VNet-bound backends is to route to a regional Application Gateway via Private Link. This gives:
| Layer | Function |
|---|---|
| Front Door | Global AnyCast, edge WAF, DDoS, caching |
| Application Gateway | Regional L7, internal WAF, path-based routing, Private Link to backends |
| Backends | App Service / VMSS / AKS / Container Apps in VNet |
The split-of-responsibilities matters: Front Door's WAF filters known attack patterns at the edge before they consume regional capacity; App Gateway's WAF can apply custom rules tailored to the regional workload's semantics. WAF rules at both layers are not redundant — they cover different threat classes.
11. Routing methods in detail
Each LB supports specific routing methods. Memorise the matrix:
| Method | Standard LB | App Gateway | Front Door | Traffic Manager |
|---|---|---|---|---|
| Round-robin / Hash-based | Yes (5-tuple) | Yes | Yes | N/A |
| Path-based | No | Yes | Yes | No |
| Header / cookie-based | No | Yes | Yes (custom rules) | No |
| Weighted | No | Yes | Yes | Yes |
| Priority (failover) | No | No | Yes | Yes |
| Geographic | No | No | Yes (rules) | Yes |
| Performance (latency) | No | No | Yes (built-in) | Yes |
| Session affinity | Source-IP | Cookie | Cookie | N/A |
The exam tests "which LB supports method X?" — keep this matrix in mind.
12. Diagnosing load-balancer issues
Common failure modes and where to look:
| Symptom | Likely cause | Diagnostic |
|---|---|---|
| All requests fail | Backend pool empty / health probes failing | Check probe path + backend health in portal |
| Some users fail | Session affinity routing to dead backend | Disable affinity temporarily; check sticky-cookie targets |
| Latency spikes globally | Front Door POP issue | Check Azure status; review per-POP metrics |
| TLS errors | Certificate mismatch or pinning issue | Check certificate chain on AppGW / FD; verify SAN |
| Failover slower than expected | Traffic Manager DNS TTL | Switch to Front Door or shorten TTL |
// Application Gateway request-failure rate
AzureDiagnostics
| where ResourceType == "APPLICATIONGATEWAYS"
| where Category == "ApplicationGatewayAccessLog"
| summarize total = count(), failures = countif(httpStatus_d >= 500)
by bin(TimeGenerated, 5m)
| extend failureRate = todouble(failures) / total
| where failureRate > 0.01[!WARNING] When migrating from Traffic Manager to Front Door, plan the cutover carefully: TM is DNS-resolved; clients cache results. Run both in parallel for 24 hours so cached TM responses expire naturally before retiring TM.
[!NOTE] The free Traffic Manager Real-User-Measurement (RUM) telemetry from end-user browsers can inform routing decisions in Performance routing mode — a useful addition for global services.
Worked Examples
Easy — internal L4 for VMSS
Problem. A VMSS of 20 VMs handles internal API traffic. Recommend.
Solution. Internal Standard Load Balancer. Place in the VNet; configure backend pool VMSS; health probe on the API port. No public exposure.
Medium — global API with regional backends
Problem. A public API hosted in 3 regions needs global low-latency routing with near-instant failover. Recommend.
Solution. Front Door Premium at global edge regional Application Gateway WAF v$2$ backend pool. Health probes from each Front Door POP detect regional failures within s; AnyCast routes around failures immediately.
Hard — multi-region with path-based routing and WAF
Problem. A SaaS has api/, web/, and admin/ paths, served globally. Admin should be geo-restricted. WAF required at edge and regional. Recommend.
Solution. Front Door Premium with WAF policy: geo-filter admin/ to allowlisted regions; OWASP managed ruleset on all paths. Front Door routes to one of two regional App Gateways (active-active across 2 regions), each with internal path-based routing for api/, web/, admin/. Internal traffic to App Services via Private Link. App Service has Standard LB inside its plan for instance-level distribution (managed by App Service).
13. App Service built-in load balancing
App Service plans have their own built-in instance-level load balancing — when you scale a plan to instances, App Service distributes traffic across them automatically without an external LB. This is sometimes overlooked: for many web workloads, an App Service plan plus deployment slots replaces App Gateway entirely.
| Need | Solution |
|---|---|
| Just distribute traffic across instances of one app | App Service built-in LB |
| Path-based routing across services | App Gateway |
| Global routing | Front Door (in front of App Service) |
| WAF | App Gateway WAF or Front Door WAF |
For simple web workloads, the cheapest sensible stack is: App Service Premium v3 (zone-redundant) plus Front Door Premium. No additional App Gateway layer needed.
14. AKS load-balancer choices
Kubernetes workloads on AKS expose services via several Azure LB patterns:
| Service type | Backed by |
|---|---|
Service: LoadBalancer (default) | Standard Load Balancer with public IP |
Service: LoadBalancer (internal) | Internal Standard LB |
Ingress controller (NGINX, AGIC) | Application Gateway via AGIC, or AKS-internal NGINX behind LB |
| Front Door Standard / Premium | Routes to AKS public LB or private origin |
Most production AKS workloads layer Front Door Application Gateway Ingress Controller (AGIC) AKS Service to combine global edge with Kubernetes-native Ingress declarations. AGIC keeps the Ingress rules in Kubernetes manifests while delegating the actual L7 traffic processing to a managed App Gateway, which Microsoft operates.
[!TIP] Use the Application Gateway Ingress Controller (
AGIC) for AKS workloads where you want declarative Ingress in Kubernetes manifests while keeping App Gateway as the actual L7 implementation. This combines GitOps-friendly config with managed L7 features.
15. TLS configuration patterns
End-to-end TLS in a layered stack has several options:
| Pattern | TLS handling |
|---|---|
| TLS termination at edge only | Front Door terminates; backend traffic via HTTP / private network |
| End-to-end TLS to backend | Front Door + App Gateway both terminate + re-encrypt; backend is HTTPS |
| TLS passthrough | Standard LB passes TLS untouched to backend (backend handles cert) |
For regulated workloads with explicit end-to-end encryption requirements, use end-to-end TLS. For most workloads, TLS termination at the edge with backend HTTP over private networks is acceptable and simpler.
16. Long-running connections — WebSockets and gRPC
WebSocket and gRPC connections are long-lived and require specific LB support to work end-to-end:
| LB | WebSocket | gRPC |
|---|---|---|
| Standard LB | Yes (L4 passthrough) | Yes (HTTP/2 over TLS) |
| App Gateway v2 | Yes (built-in) | Yes (from 2024 GA) |
| Front Door | Yes (Premium tier full support) | Yes (Premium) |
| Traffic Manager | N/A (DNS only) | N/A (DNS only) |
[!IMPORTANT] Long-lived connection workloads benefit from session affinity to avoid frequent reconnects. Configure
Cookie-Based Affinityon App Gateway or session affinity on Front Door for WebSocket workloads.
Visual Explanations
Figure 1 — Decision flow
Figure 2 — Failover speed comparison
Figure 3 — Quick chooser
| Need | Service |
|---|---|
| Internal L4 in one region | Standard LB |
| Internal L7 with WAF, one region | Application Gateway WAF v2 |
| Public HTTP, global, fast failover | Front Door |
| Public HTTP, global, WAF | Front Door Premium |
| Global non-HTTP (DNS-based) | Traffic Manager |
| Internal NVA fleet (HA ports) | Standard LB |
| Path-based routing | Application Gateway (or Front Door) |
| Geo-restriction | Front Door WAF policy or Traffic Manager Geographic |
Common Mistakes
❌ Myth: "Traffic Manager gives the fastest global failover." ✅ Reality: Traffic Manager failover is bounded by DNS TTL. Front Door's AnyCast at the network layer gives much faster failover (seconds vs minutes).
❌ Myth: "Basic LB is fine for non-production." ✅ Reality: Basic is retiring. Use Standard everywhere; the cost gap is small.
❌ Myth: "App Gateway and Front Door are interchangeable." ✅ Reality: App Gateway is regional (within a VNet); Front Door is global edge. They serve different scopes and combine.
❌ Myth: "Health probes are an implementation detail." ✅ Reality: Probe configuration drives failover correctness and speed. Pick a probe path that genuinely reflects backend health (not just a 200 on
/).
Practice Exercises
🟢 Exercise 1. An internal API hosted on 10 VMs needs L4 distribution. Recommend.
▶✅ Solution
Internal Standard Load Balancer.
🟡 Exercise 2. A public API with and paths needs WAF and regional routing. Recommend.
▶✅ Solution
Application Gateway WAF v$2$ with URL path-based routing. Front Door optional for global edge.
🟡 Exercise 3. A non-HTTP SMTP service has 3 regional endpoints. Global failover needed. Recommend.
▶✅ Solution
Traffic Manager with Priority routing. Front Door is HTTP-only; Standard LB is regional only.
🔴 Exercise 4. A team uses Traffic Manager for HTTP traffic; failover during region outages takes minutes. Recommend.
▶✅ Solution
Replace with Front Door. AnyCast routes around failures at the network layer without waiting on client DNS cache.
🔴 Exercise 5. An NVA fleet (5 Palo Alto VMs) needs HA across all ports / protocols. Recommend.
▶✅ Solution
Standard LB with HA Ports rule. Single rule distributes all ports / protocols to the NVA pool.
🟢 Exercise 6. True or false: Front Door supports non-HTTP traffic.
▶✅ Solution
False. Front Door is HTTP/HTTPS only. Non-HTTP global routing requires Traffic Manager.
🟡 Exercise 7. Sketch Bicep for a zone-redundant Standard LB.
▶✅ Solution
resource lb 'Microsoft.Network/loadBalancers@2024-03-01' = {
name: 'lb-prod'
location: location
sku: { name: 'Standard' }
properties: {
frontendIPConfigurations: [ { name: 'fe', properties: { subnet: { id: subnetId }, privateIPAllocationMethod: 'Dynamic' }, zones: ['1','2','3'] } ]
backendAddressPools: [ { name: 'be' } ]
probes: [ { name: 'http', properties: { protocol: 'Http', port: 80, requestPath: '/health', intervalInSeconds: 5, numberOfProbes: 2 } } ]
loadBalancingRules: [ /* rules */ ]
}
}Figure 4 — Multi-region active-active topology
A canonical multi-region active-active for HTTP:
| Layer | Component | Notes |
|---|---|---|
| Edge | Front Door Premium | AnyCast, WAF, DDoS |
| Regional (West Europe) | App Gateway WAF v2 ZR | Routes to backends |
| Regional (East US 2) | App Gateway WAF v2 ZR | Mirror |
| Regional (Southeast Asia) | App Gateway WAF v2 ZR | Mirror |
| Backend | App Service Premium v3 ZR / Container Apps | Stateless |
| State | Cosmos DB multi-region, Azure SQL Failover Group, Storage GZRS | Multi-region data |
Front Door's health probes detect regional issues within roughly 30 seconds; AnyCast routes around them; users in each geography see the nearest healthy region without any visible delay.
Figure 5 — Hub-spoke with internal load balancing
For private-only internal workloads:
| Layer | Component |
|---|---|
| Client | On-prem via ExpressRoute |
| Spoke ingress | Internal App Gateway (no public IP) |
| App | VMSS / Container Apps |
| L4 | Internal Standard LB (for direct VM backends) |
| State | Private Endpoint to PaaS |
No Front Door, no Traffic Manager — entirely internal. This is the common pattern for B2B intranet workloads in regulated industries.
Figure 6 — Cost-vs-features comparison
A rough cost ranking at moderate traffic:
| Service | Approximate monthly cost |
|---|---|
| Standard LB | Low (/month at moderate traffic) |
| Traffic Manager | Very low (/month) |
| Application Gateway v2 | Moderate (/month) |
| Application Gateway WAF v2 | Moderate-high (/month) |
| Front Door Standard | Moderate ( + per-request) |
| Front Door Premium | High ( + per-request) |
The right answer is consistently the cheapest service that genuinely fits the workload's requirements — not the most-featured one or the most-fashionable one in the marketing materials.
Summary & Concept Map
- Four LBs, four scopes. Standard LB (L4 regional), App Gateway (L7 regional), Front Door (L7 global AnyCast), Traffic Manager (DNS global).
- Front Door beats Traffic Manager for fast failover on HTTP workloads.
- App Gateway WAF v2 inside a region; Front Door Premium at the edge — combine for layered defence + routing.
- Basic LB retiring. Standard everywhere in production.
- Health probes drive failover correctness. Configure probe paths and intervals deliberately.
- HA Ports for NVA fleets.