Elastic Load Balancing distributes traffic across targets. Application Load Balancer (ALB) handles HTTP/HTTPS at Layer 7; Network Load Balancer (NLB) handles TCP/UDP at Layer 4 with extreme performance.
ALB features
- Path-based routing (
/api/*→ one target group) - Host-based routing (
api.example.com) - Health checks remove unhealthy EC2/tasks
- SSL termination at the load balancer
Typical architecture
Internet → ALB (public subnets) → EC2/ECS tasks (private subnets) → RDS. Django behind Gunicorn registers as ALB target on port 8000.
List load balancers
aws elbv2 describe-load-balancers \
--query 'LoadBalancers[].{Name:LoadBalancerName,Type:Type,DNS:DNSName}' \
--output tablePractice: Create S3 buckets and VPC resources only in a sandbox account. Use unique bucket names globally; delete buckets and empty objects when finished.
Cost: ALB/NLB bill hourly plus LCU usage—delete sandbox load balancers when done.
Important interview questions and answers
- Q: ALB vs NLB?
A: ALB for HTTP routing and host/path rules; NLB for low-latency TCP/UDP passthrough. - Q: Health check purpose?
A: Stop sending traffic to failed instances until they recover or are replaced.
Self-check
- What layer does an ALB operate at?
- Why terminate SSL at the load balancer?
Tip: Delete sandbox ALBs when done—they bill hourly even with no traffic.
Interview prep
- ALB vs NLB?
ALB Layer 7 HTTP routing; NLB Layer 4 high-performance TCP/UDP.
- Health check?
Removes unhealthy targets so users only hit working instances.