Azure Load Balancer: Layer 4
Master Azure Load Balancer β SKU comparison, public vs internal, components, SNAT port exhaustion, cross-region load balancing, and Gateway Load Balancer.
Azure Load Balancer: Layer 4
Azure Load Balancer distributes traffic at Layer 4 (TCP/UDP). It doesnβt inspect HTTP headers or URLs β it routes packets based on IP address, port, and protocol. Fast, efficient, and the foundation of Azureβs load balancing story.
π¬ Video coming soon
Azure Load Balancer Deep Dive
Azure Load Balancer Deep Dive
~14:00A load balancer is a traffic cop at a busy intersection β it directs incoming traffic to different servers so no single server gets overwhelmed. Azure Load Balancer works at Layer 4 (TCP/UDP) β it distributes based on IP addresses and ports, not URLs. It doesnβt inspect content β it just routes packets to healthy backends.
Load Balancer SKUs
| Feature | Basic (Retiring) | Standard | Gateway |
|---|---|---|---|
| Backend pool size | 300 instances | 1,000 instances | 1,000 instances |
| Health probes | TCP, HTTP | TCP, HTTP, HTTPS | TCP, HTTP, HTTPS |
| Availability zones | Not supported | Zone-redundant and zonal | Zone-redundant |
| HA Ports | No | Yes (all ports on internal LB) | Yes (transparent) |
| Outbound rules | No (default SNAT only) | Yes (configurable SNAT) | N/A |
| SLA | No SLA | 99.99% | 99.99% |
| Security | Open by default | Secure by default (NSG required) | Secure by default |
| Status | Retiring 30 Sept 2025 | Current β use this | Specialised (NVA chaining) |
| Cost | Free | Per rule + per GB | Per rule + per GB |
Exam Tip: Basic LB is retiring on 30 September 2025 (same date as Basic public IPs β theyβre linked). Always choose Standard for new deployments. Standard LB requires Standard SKU public IPs and is secure by default (inbound traffic blocked until an NSG allows it).
Public vs Internal Load Balancer
| Type | Frontend IP | Use Case |
|---|---|---|
| Public | Public IP address | Internet-facing workloads (web servers, APIs) |
| Internal | Private IP from your subnet | Internal workloads (app tiers, databases, internal APIs) |
You can have both on the same set of backend VMs β a public LB for internet traffic and an internal LB for backend-tier traffic.
The 6 Components
- Frontend IP configuration β the IP clients connect to (public or private)
- Backend pool β the VMs or instances that receive traffic
- Health probes β check if backend instances are healthy
- Load balancing rules β map frontend IP:port to backend pool (uses 5-tuple hash: source IP, source port, destination IP, destination port, protocol)
- Inbound NAT rules β port forward specific frontend ports to specific backend instances (e.g., frontend port 50001 to VM1 port 3389)
- Outbound rules β control SNAT for outbound internet traffic from backend pool members
Distribution modes:
| Mode | Hash | Behaviour |
|---|---|---|
| Default (5-tuple) | Source IP + port + Dest IP + port + Protocol | Different connections may go to different backends |
| Source IP affinity (2-tuple) | Source IP + Dest IP | Same client IP always goes to same backend |
| Source IP affinity (3-tuple) | Source IP + Dest IP + Protocol | Same client and protocol always goes to same backend |
SNAT Port Exhaustion β A Common Production Issue
When backend VMs use the load balancer for outbound internet traffic (no public IP, no NAT Gateway), they share SNAT ports from the frontend IP.
The problem: Each frontend IP provides approximately 64,000 SNAT ports. With many VMs making outbound connections (e.g., calling external APIs), ports can be exhausted. Symptoms: intermittent connection failures, timeouts, βcannot allocate portβ errors.
Solutions (in order of preference):
- NAT Gateway β best practice. Provides 64,000 ports per IP per destination. Scales with multiple IPs.
- Outbound rules β explicitly allocate SNAT ports per backend instance. Provides more predictable allocation.
- Multiple frontend IPs β more frontends = more SNAT ports (64,000 per IP).
- Public IP on VMs β each VM gets its own 64,000 ports. Doesnβt scale well.
Monitoring: Track the βSNAT Connection Countβ metric. Alert when approaching limits.
The exam tests that you know NAT Gateway is the recommended solution for SNAT port exhaustion.
Cross-Region Load Balancer
Cross-region LB (global tier) distributes traffic across regional Standard LBs in different Azure regions:
Client (anywhere)
β
Cross-Region LB (Global anycast IP)
ββββ Standard LB (Australia East)
β ββββ Backend VMs
ββββ Standard LB (West Europe)
ββββ Backend VMs
Key features:
- Anycast IP β single IP address that routes to the nearest healthy region
- Geographic proximity β clients connect to the closest regional LB
- Instant failover β if a regional LB becomes unhealthy, traffic shifts to the next closest
- Layer 4 only β still TCP/UDP, not HTTP-aware
Use cross-region LB when you need global Layer 4 distribution with automatic regional failover. For HTTP-aware global distribution, use Azure Front Door instead.
Gateway Load Balancer
Gateway LB enables transparent NVA chaining β inserting network virtual appliances (firewalls, packet inspection, DDoS appliances) into the traffic path without changing the application architecture.
How it works:
- Gateway LB sits in front of NVAs in a separate VNet
- Your Standard LBβs frontend configuration is βchainedβ to the Gateway LB
- Traffic flows: Client β Standard LB β Gateway LB β NVA β Gateway LB β Backend VMs
- The application and clients see no change β itβs transparent
Use case: A third-party security vendor provides a firewall appliance. Instead of re-architecting your application, you chain the Gateway LB to inject the NVA into the existing traffic flow.
Key Takeaways
- Standard LB is the only production choice (Basic retiring, Gateway is specialised)
- Standard LB is secure by default β NSG required for inbound traffic
- 5-tuple hash distributes connections; source IP affinity provides session persistence
- NAT Gateway is the recommended solution for SNAT port exhaustion
- Cross-region LB uses anycast for global Layer 4 distribution
- Gateway LB transparently chains NVAs into traffic flows
Test Your Knowledge
Sam's backend VMs are experiencing intermittent outbound connection failures. Monitoring shows high SNAT port usage. What's the recommended fix?
Ravi needs global Layer 4 load balancing with automatic failover between Australia East and West Europe. What should he deploy?
Next up: Traffic Manager: DNS-Based Routing β Route traffic globally using DNS with six different routing methods.