Chapter 13: AWS Elastic Load Balancing
AWS Cloud Elastic Load Balancing (usually just called ELB or Elastic Load Balancing).
This is one of the most important services in AWS for real-world production apps — especially when you’re using EC2 Auto Scaling (which we talked about last time). Without a load balancer, all your traffic hits one server → single point of failure, slow response during peaks, no smart routing.
Think of Elastic Load Balancing as the smart traffic cop standing at the entrance of your building (app):
- Directs cars (requests) to the right parking spots (EC2 instances, containers, Lambda, etc.).
- If one spot is full/broken → redirects to others.
- Handles rush hour automatically.
- Checks VIP passes (HTTPS, authentication).
- Spreads load evenly so no one spot gets jammed.
In Hyderabad terms: Imagine during IPL finals, everyone rushes to your food delivery app. Without ELB → one server crashes. With ELB → traffic splits across 10 servers in different AZs → fast delivery, no crashes.
Let’s go deep, step-by-step, like a real classroom whiteboard session — what it is, how it works, the 4 types (2026 current), features, examples, and a mini hands-on feel.
1. What is Elastic Load Balancing (ELB)? (Official + Simple 2026 Definition)
Elastic Load Balancing = a fully managed AWS service that automatically distributes incoming application traffic across multiple targets (EC2 instances, ECS containers, IP addresses, Lambda functions, etc.) in one or more Availability Zones (AZs).
Key words:
- Automatic → scales with traffic (no manual config for most cases).
- Distributes → even spread + health checks.
- Managed → AWS handles hardware, patching, availability.
- High availability → built-in across AZs (99.99%+ SLA).
How it works at high level:
- Clients (browsers, mobile apps) hit a single DNS name (e.g., myapp.loadbalancer.aws).
- ELB receives request.
- Routes to healthy targets based on rules.
- If target unhealthy → removes it from rotation.
- Returns response to client.
No single point of failure — ELB itself is distributed.
2. The 4 Types of Load Balancers in Elastic Load Balancing (2026 – Current)
AWS offers four types under ELB. Classic is legacy — most people use the modern three.
| Type | OSI Layer | Protocols | Best For (2026 Use Cases) | Key Strength | When to Choose in Hyderabad Projects |
|---|---|---|---|---|---|
| Application Load Balancer (ALB) | Layer 7 (Application) | HTTP, HTTPS, HTTP/2, gRPC, WebSocket | Modern web/microservices, content-based routing, path/host-based rules, Lambda targets | Advanced routing, WAF integration, easiest for web apps | Almost all web/API apps (Zomato-like, e-commerce) |
| Network Load Balancer (NLB) | Layer 4 (Transport) | TCP, TLS, UDP | Ultra-low latency, high throughput, millions RPS, static IP, non-HTTP (gaming, VoIP) | Extreme performance, preserves source IP | Gaming servers, fintech payments, streaming |
| Gateway Load Balancer (GLB / GWLB) | Layer 3 (Network) + Layer 4 | IP (any protocol) | Deploy/scale 3rd-party appliances (firewalls, IDS/IPS, deep packet inspection) | Transparent insertion of security appliances | Security-heavy (banks, enterprises with Palo Alto, Fortinet) |
| Classic Load Balancer (CLB) | Layer 4/7 (mixed) | TCP, HTTP, HTTPS | Legacy EC2-Classic, very old apps (avoid new use) | Basic, simple | Migrate away — use ALB/NLB instead |
2026 reality:
- ALB is the most popular (80%+ new setups) — flexible, cheap for HTTP.
- NLB for performance-critical.
- GLB niche for security chains.
- Classic → only if stuck with old VPC/EC2-Classic (AWS pushes migration).
3. Key Features Common to All (or Most) Types
- Health checks → Ping targets (HTTP 200, TCP connect) → route only to healthy.
- Auto scaling integration → Works perfectly with EC2 Auto Scaling Groups (ASG) — registers new instances automatically.
- High availability → Nodes in multiple AZs.
- Security → SSL/TLS termination (offload certs to ELB), AWS WAF (on ALB), client cert auth.
- Monitoring → CloudWatch metrics (latency, requests, errors), access logs to S3.
- Sticky sessions (session affinity) — ALB & NLB support.
- Connection draining → Graceful shutdown.
- IPv6/Dualstack support.
- Pricing → Per hour + per GB processed (very low — e.g., ALB ~₹1,500–3,000/month for moderate traffic in ap-south-1).
4. Real Hyderabad Example: ALB in Action (Most Common Scenario)
Your startup’s food delivery web/mobile app:
- 5 EC2 instances (t3.medium) in Auto Scaling Group (min 2, max 20) across 3 AZs in ap-south-2 Hyderabad.
- Traffic: Normal 1,000 users → peak lunch 10,000+.
Setup with ALB:
- Create ALB → internet-facing, scheme internet-facing.
- Listeners: HTTPS:443 (with ACM cert), HTTP:80 (redirect to HTTPS).
- Target group: Register your ASG instances (or by IP).
- Routing rules:
- Path /api/orders → target group “orders”
- Path /api/payments → target group “payments”
- Host mobile.myapp.com → mobile-specific rules
- Health check: /health → HTTP 200.
What happens:
- User opens app → hits ALB DNS (myapp-123456.ap-south-2.elb.amazonaws.com).
- ALB inspects HTTP headers → routes /api/orders to healthy instances in “orders” group.
- During rush: ASG scales to 12 instances → ALB auto-registers new ones → distributes evenly.
- One instance CPU 100% → health check fails → ALB stops sending traffic → ASG replaces it.
- SSL handled by ALB → instances get plain HTTP (cheaper CPU).
- WAF attached → blocks SQL injection attempts.
Result: App stays up during festivals, fast response, secure — cost ~₹2,000–5,000/month for ALB + instances.
Without ALB → all traffic to one IP → crash or slow.
5. Quick Comparison: ALB vs NLB (Most Asked Question)
| Feature | ALB (Layer 7) | NLB (Layer 4) |
|---|---|---|
| Routing basis | Content (path, host, headers, query) | IP + port |
| Latency | Slightly higher | Ultra-low |
| Static IP / Elastic IP | No | Yes (one per AZ) |
| Preserve source IP | No (uses X-Forwarded-For) | Yes |
| WebSocket/gRPC | Yes | Yes (TCP) |
| WAF integration | Yes | No |
| Lambda targets | Yes | No |
| Typical cost | Lower for HTTP | Slightly higher for raw perf |
Choose ALB for 90% web/API cases. NLB for gaming, IoT, or need static IP.
6. Mini Hands-On Suggestion (Free Tier Friendly)
- Launch 2 t3.micro EC2 in different AZs (install simple nginx: “Hello from Hyderabad”).
- Create ALB → internet-facing, HTTPS listener (free ACM cert).
- Create target group → register 2 instances.
- Point DNS (or browser) to ALB DNS → see traffic split!
Cost? Usually ₹0–50 for testing.
Quick Summary Table – ELB Cheat Sheet
| Question | Answer (Beginner Level) |
|---|---|
| What is ELB? | Managed service to distribute traffic across targets |
| Main types? | ALB (web), NLB (perf), GLB (security), Classic (legacy) |
| Works best with? | EC2 Auto Scaling + multi-AZ |
| Key benefit? | High availability, auto-healing, smart routing |
| Pricing? | Hourly + LCU/GB (low for most) |
| First choice for web app? | Application Load Balancer (ALB) |
ELB is the “glue” that makes your scalable, highly available app real — pair it with Auto Scaling for magic.
Got it? Want next:
- Step-by-step create ALB + target group?
- ALB advanced routing rules deep dive?
- Or ELB vs API Gateway?
Tell me — next class ready! 🚀⚖️
