How do Elastic Load Balancers work in AWS?
Learn how AWS Elastic Load Balancers distribute traffic, run health checks, and provide high availability, plus ALB vs NLB differences explained.
Expected Interview Answer
An Elastic Load Balancer (ELB) automatically distributes incoming traffic across multiple healthy targets, such as EC2 instances or containers, spread over Availability Zones, so no single resource is overwhelmed and failed targets are bypassed.
ELB continuously runs health checks and routes requests only to targets that pass. AWS offers Application Load Balancers (Layer 7, HTTP/HTTPS with path and host routing), Network Load Balancers (Layer 4, ultra-low-latency TCP/UDP), and Gateway Load Balancers (for third-party appliances). Combined with Auto Scaling, an ELB provides high availability, fault tolerance, and elastic capacity behind a single stable endpoint.
- Even traffic distribution across healthy targets
- High availability across multiple Availability Zones
- Automatic detection and bypass of unhealthy targets
- SSL/TLS termination offloaded from backends
- Seamless scaling when integrated with Auto Scaling groups
AI Mentor Explanation
An ELB is like a captain rotating the bowling attack so no single bowler tires out: deliveries (requests) are spread across fit bowlers, and any bowler nursing an injury is quietly kept out of the over until a fitness check clears him to return to the attack.
Step-by-Step Explanation
Step 1
Choose the load balancer type
Pick an Application (L7), Network (L4), or Gateway Load Balancer based on protocol and routing needs.
Step 2
Register targets
Create a target group and register EC2 instances, IPs, containers, or Lambda functions as backends.
Step 3
Configure health checks
Define a health check path/port and thresholds so only healthy targets receive traffic.
Step 4
Set up listeners and rules
Add listeners (e.g., HTTPS:443) with routing rules for host/path, and optionally terminate TLS.
Step 5
Distribute across AZs
Enable multiple Availability Zones and pair with an Auto Scaling group for elasticity and fault tolerance.
What Interviewer Expects
- Understanding of traffic distribution and high availability
- Difference between ALB (L7), NLB (L4), and Gateway LB
- Role of health checks in routing decisions
- Integration with Auto Scaling groups
- Concept of listeners, target groups, and TLS termination
Common Mistakes
- Confusing Application (L7) and Network (L4) load balancers
- Forgetting to configure health checks, causing traffic to unhealthy targets
- Deploying targets in a single AZ, defeating high availability
- Assuming ELB creates capacity rather than distributing across existing targets
Best Answer (HR Friendly)
“An Elastic Load Balancer spreads incoming traffic across many servers so none get overwhelmed. It constantly checks which servers are healthy and only sends requests to working ones, keeping applications fast and available even if some servers fail.”
Code Example
# Create an internet-facing Application Load Balancer across two subnets
aws elbv2 create-load-balancer \
--name app-alb \
--type application \
--subnets subnet-0aaa111 subnet-0bbb222 \
--security-groups sg-0ccc333
# Create a target group with a health check
aws elbv2 create-target-group \
--name web-tg \
--protocol HTTP --port 80 \
--vpc-id vpc-0abc123 \
--health-check-path /healthz
# Add an HTTPS listener that forwards to the target group
aws elbv2 create-listener \
--load-balancer-arn arn:aws:elasticloadbalancing:...:loadbalancer/app/app-alb/abc \
--protocol HTTPS --port 443 \
--default-actions Type=forward,TargetGroupArn=arn:aws:...:targetgroup/web-tg/defFollow-up Questions
- When would you choose an NLB over an ALB?
- How do health checks influence routing decisions?
- How does ELB integrate with Auto Scaling?
- What is SSL/TLS termination at the load balancer?
MCQ Practice
1. Which load balancer operates at Layer 7 and supports host/path-based routing?
The Application Load Balancer works at Layer 7 (HTTP/HTTPS) and can route by host and path; the NLB operates at Layer 4.
2. What determines whether a target receives traffic from an ELB?
ELB routes only to targets that pass their health checks; failing targets are automatically bypassed until they recover.
3. Which load balancer is best for ultra-low-latency Layer 4 TCP/UDP traffic?
The Network Load Balancer operates at Layer 4 and is designed for high-throughput, low-latency TCP/UDP workloads.
Flash Cards
What is an ELB? — A service that distributes incoming traffic across multiple healthy targets in one or more Availability Zones.
ALB vs NLB — ALB is Layer 7 (HTTP/HTTPS, host/path routing); NLB is Layer 4 (TCP/UDP, ultra-low latency).
Role of health checks — ELB routes only to targets passing health checks and bypasses unhealthy ones automatically.
ELB + Auto Scaling — New instances register with the target group automatically, giving elastic capacity and fault tolerance.