Understand Application, Network, and Gateway Load Balancers. Learn how ALB routing rules and Auto Scaling Groups work together.
ELB — Distributing Traffic Across Servers
A Load Balancer distributes incoming requests across multiple servers so no single server gets overwhelmed. If one server fails, the load balancer automatically stops sending it traffic.
Teacher Note: Imagine a busy restaurant with 4 waiters. The manager (load balancer) assigns tables evenly — if one waiter calls in sick, the manager gives their tables to others. Customers never notice anything is wrong.
Three Types of AWS Load Balancers
| Load Balancer | Layer | Key Features | Best For |
|---|
| Application Load Balancer (ALB) | Layer 7 (HTTP/HTTPS) | Path routing, host routing, WebSockets, gRPC, WAF, Cognito auth | Web applications, microservices, REST APIs |
| Network Load Balancer (NLB) | Layer 4 (TCP/UDP) | Millions of req/second, ultra-low latency, static IP per AZ, TLS passthrough | Gaming, trading, IoT, VoIP |
| Gateway Load Balancer (GWLB) | Layer 3 (IP) | Routes traffic through 3rd-party virtual appliances | Firewalls, deep packet inspection, IDS/IPS |
ALB — Path and Host-Based Routing
ALB Routing Rules:
If URL starts with /api/* --> Route to Backend API servers
If URL starts with /images/* --> Route to Image servers
If Host is admin.example.com --> Route to Admin servers
If Host is api.example.com --> Route to API servers
Default: Forward to main application
Auto Scaling with Load Balancers
Combine ALB with Auto Scaling Groups for the most common exam pattern:
- ALB receives all traffic and distributes it
- Auto Scaling Group automatically adds EC2 instances when traffic increases
- Auto Scaling Group removes EC2 instances when traffic decreases
- New instances are automatically registered with the ALB's Target Group
- If an instance fails health checks, ALB stops sending it traffic AND ASG replaces it
Exam Tip: ALB vs NLB is a common exam question. Remember: ALB = Layer 7 HTTP/HTTPS, path/host-based routing, WebSockets. NLB = Layer 4 TCP/UDP, static IP, millions of requests per second, ultra-low latency. If the question mentions static IP — it is NLB.