Why Load Balancing Matters
In Azure, applications must be reliable and scalable. Load balancers spread incoming traffic across multiple resources, ensuring high availability and fault tolerance.
Azure Load Balancer (Layer 4)
-
Operates at Layer 4 (Transport Layer – TCP/UDP).
-
Distributes inbound traffic across healthy VMs.
-
Supports inbound and outbound connections.
-
Works with public IPs (internet-facing) or private IPs (internal).
-
Includes health probes to ensure traffic only goes to healthy instances.
Use Cases:
-
Distribute traffic across VM scale set.
-
Provide failover between multiple VMs in the same tier.
Application Gateway (Layer 7)
-
Operates at Layer 7 (Application Layer – HTTP/HTTPS).
-
Provides application-level routing.
-
Supports URL-based routing (e.g.,
/images → VM1,/videos → VM2). -
Includes Web Application Firewall (WAF) for protection against threats like SQL injection and cross-site scripting.
-
Supports SSL termination, cookie-based session affinity, and end-to-end TLS.
Use Cases:
-
Route web traffic based on URL path or host headers.
-
Protect apps with WAF.
-
Load balance traffic across multiple web apps or services.
Confusion Buster 🚨
-
Load Balancer vs Application Gateway
-
Load Balancer = Layer 4, TCP/UDP, distributes traffic blindly.
-
Application Gateway = Layer 7, HTTP/HTTPS, smart routing + WAF.
-
-
Exam trick: If the question says “distribute HTTP requests based on URL path”, it’s Application Gateway. If it says “spread TCP traffic across VMs”, it’s Load Balancer.
Simple Example
A company hosts:
-
Web frontend (HTTP/HTTPS).
-
Database backend.
They use:
-
Application Gateway for the web tier → routes
/apito one pool and/appto another, with WAF enabled. -
Internal Load Balancer for the database tier → balances SQL traffic across multiple VMs.
Exam Tip
-
Always look for keywords:
-
“URL-based routing” → Application Gateway.
-
“Web Application Firewall (WAF)” → Application Gateway.
-
“TCP traffic load balancing” → Load Balancer.
-
“Distribute across VMs in scale set” → Load Balancer.
-
What to Expect in the Exam
-
Direct Q: “Which Azure service provides Layer 7 load balancing with WAF?” → Application Gateway.
-
Scenario: “Distribute TCP traffic across VMs in backend pool.” → Azure Load Balancer.
-
Trick Q: “Azure Load Balancer can inspect HTTP headers.” (False — only Application Gateway can).