Elastic Load Balancing (ELB)
| Load Balancer | Layer | Protocol | Use Case |
|---|---|---|---|
| ALB | 7 (HTTP) | HTTP, HTTPS, WebSocket | Microservices, containers, path/header routing |
| NLB | 4 (TCP/UDP) | TCP, TLS, UDP | Extreme performance, static IP, millions req/sec |
| GWLB | 3 (Network) | IP Packets | Third-party network appliances (firewalls, IDS) |
| CLB (legacy) | 4 & 7 | HTTP, HTTPS, TCP | Deprecated, avoid |
ALB routing: URL path (/users, /posts), hostname, query strings, headers. Target groups can be EC2 instances, ECS tasks, Lambda functions, IP addresses.
ALB Good to Know: Fixed hostname. Client IP is in X-Forwarded-For header (EC2 won't see the real client IP directly). Supports SNI (multiple SSL certs per listener). HTTP → HTTPS redirect.
NLB Good to Know: One static IP per AZ (can assign Elastic IP). Ultra-low latency. Target groups: EC2, IP addresses, or ALB. Health checks support TCP, HTTP, HTTPS.
GWLB: Uses GENEVE protocol on port 6081. Transparent gateway + load balancer for security appliances. All traffic passes through 3rd-party virtual appliances.
Cross-Zone Load Balancing: ALB = enabled by default, no charge. NLB/GWLB = disabled by default, you pay for cross-AZ data if enabled. CLB = disabled by default, no charge if enabled.
Sticky Sessions (Session Affinity): Same client always goes to same instance. Uses cookies. ALB: application-based (AWSALBAPP) or duration-based (AWSALB) cookies. Can cause load imbalance.
Connection Draining / Deregistration Delay: Time to complete in-flight requests when deregistering. Default 300s (1-3600s). Set low for short requests.
SNI (Server Name Indication): Allows loading multiple SSL certs on one web server. ALB + NLB support it. CLB does NOT.
Health Checks: ELB sends requests to a port/path. Must return 200 OK to be considered healthy.
