ALB vs NLB vs GLB vs CLB: Which Load Balancer Should You Choose?
ALB for HTTP/HTTPS apps, NLB for TCP/UDP high-performance workloads, GLB for security appliances. Master ELB type differences for SAA-C03 exam.
Related Exam Domains
- Domain 2: Design Resilient Architectures
Key Takeaway
ALB is for HTTP/HTTPS web applications (L7), NLB is for TCP/UDP high-performance workloads (L4), GLB is for third-party security appliances. Choose ALB for web/API services, NLB when you need ultra-low latency or static IPs, GLB for firewall/IDS integration. CLB is legacy and not recommended for new deployments.
Exam Tip
Exam Essential: ALB = L7 + HTTP + path routing, NLB = L4 + TCP/UDP + static IP + low latency, GLB = security appliances
What are AWS Load Balancers?
Elastic Load Balancing (ELB) is a service that automatically distributes incoming traffic across multiple targets (EC2, containers, Lambda, etc.). It provides high availability and fault tolerance with 4 types available.
Client Request → Load Balancer → Target Group (EC2, Containers, Lambda)
↓
Health Check excludes unhealthy instances
ELB 4 Types at a Glance
| Comparison | ALB | NLB | GLB | CLB |
|---|---|---|---|---|
| OSI Layer | Layer 7 | Layer 4 | Layer 3 | Layer 4/7 |
| Protocol | HTTP, HTTPS, gRPC | TCP, UDP, TLS | IP | TCP, HTTP, HTTPS |
| Latency | ~10ms | ~100μs (ultra-low) | - | Medium |
| Static IP | ❌ | ✅ | ❌ | ❌ |
| Path-based Routing | ✅ | ❌ | ❌ | ❌ |
| Host-based Routing | ✅ | ❌ | ❌ | ❌ |
| Lambda Target | ✅ | ❌ | ❌ | ❌ |
| PrivateLink | ❌ | ✅ | ✅ | ❌ |
| Released | 2016 | 2017 | 2020 | 2009 |
| Recommended | ✅ Yes | ✅ Yes | ✅ Yes | ❌ Legacy |
Application Load Balancer (ALB)
What is ALB?
ALB operates at OSI Layer 7 (application layer). It understands HTTP/HTTPS traffic and can route based on URL paths, host headers, HTTP headers, and more.
Key Features
1. Path-based Routing
example.com/api/* → API server target group
example.com/images/* → Image server target group
example.com/* → Web server target group
2. Host-based Routing
api.example.com → API target group
www.example.com → Web target group
3. Various Target Types
- EC2 instances
- IP addresses (including on-premises)
- Lambda functions
- ECS/EKS containers
ALB Ideal Workloads
- Web applications (HTTP/HTTPS)
- Microservices architecture
- Container-based applications (ECS, EKS)
- API Gateway alternative
- Lambda function invocation
Exam Tip
Exam Pattern: "In a microservices setup, route /users to User Service and /orders to Order Service?" → ALB path-based routing
Network Load Balancer (NLB)
What is NLB?
NLB operates at OSI Layer 4 (transport layer) and provides ultra-high-performance load balancing at the TCP/UDP protocol level. It can handle millions of requests per second with less than 100 microseconds latency.
Key Features
1. Static IP Addresses
- One static IP per AZ
- Elastic IP attachable
- Useful for firewall whitelisting
2. Ultra-low Latency
- ~100x lower latency than ALB
- Millions of requests per second
3. Source IP Preservation
- Maintains client's original IP address
- No X-Forwarded-For header needed
4. Long-lived TCP Connections
- WebSocket
- Database connections
- Game servers
NLB Ideal Workloads
- Real-time game servers (UDP)
- IoT device connections
- Financial trading systems (ultra-low latency)
- Media streaming
- VoIP services
- Services requiring static IPs
- Direct TCP/UDP protocol usage
Exam Tip
Exam Pattern: "Customer needs to whitelist specific IPs. Which load balancer?" → NLB (provides static IP)
Gateway Load Balancer (GLB)
What is GLB?
GLB operates at Layer 3 (network layer) and is used to deploy and scale third-party virtual appliances (firewalls, IDS/IPS, etc.).
Key Features
1. Transparent Network Gateway
- All traffic passes through appliances
- Single entry/exit point
2. Auto Scaling
- Scale appliances based on traffic
- Health Check excludes failed appliances
3. GENEVE Protocol
- Encapsulates original packets
- Returns after appliance inspection
GLB Ideal Workloads
- Third-party firewalls (Palo Alto, Fortinet, etc.)
- Intrusion Detection/Prevention Systems (IDS/IPS)
- Deep Packet Inspection (DPI)
- Network monitoring
Exam Tip
Exam Pattern: "Inspect all VPC traffic through third-party firewall appliances?" → Gateway Load Balancer
Classic Load Balancer (CLB)
What is CLB?
CLB is AWS's original load balancer (2009) that provides basic load balancing at both Layer 4 and Layer 7. Not recommended for new deployments.
CLB Limitations
- No path/host-based routing
- Limited WebSocket support
- Single SSL certificate only
- No container targets
Migration Recommended
AWS recommends migrating from CLB to ALB or NLB:
- HTTP/HTTPS → ALB
- TCP/UDP → NLB
ALB vs NLB: When to Choose Which?
Selection Criteria Summary
| Requirement | Choice |
|---|---|
| HTTP/HTTPS traffic | ALB |
| URL path-based routing | ALB |
| Host-based routing | ALB |
| Lambda function invocation | ALB |
| gRPC protocol | ALB |
| TCP/UDP traffic | NLB |
| Static IP address needed | NLB |
| Ultra-low latency required | NLB |
| Millions of requests/sec | NLB |
| Source IP preservation | NLB |
| WebSocket (long-lived) | NLB |
Real-World Scenario Selection
Scenario 1: Web Application
Requirement: HTTP/HTTPS traffic, separate /api and /web routing
→ ALB (path-based routing)
Scenario 2: Online Gaming
Requirement: UDP protocol, ultra-low latency, massive concurrent connections
→ NLB (L4, UDP support, high performance)
Scenario 3: Microservices
Requirement: Different URL paths per service, ECS containers
→ ALB (path-based routing, container support)
Scenario 4: Financial Trading System
Requirement: TCP, ultra-low latency, fixed IP for partner integration
→ NLB (static IP, ultra-low latency)
Scenario 5: Security Inspection
Requirement: Route all traffic through third-party firewall
→ GLB (appliance integration)
ELB Common Features
Features available across all ELB types:
| Feature | Description |
|---|---|
| Health Check | Monitor target status, exclude unhealthy targets |
| High Availability | Auto-distribute across multiple AZs |
| Auto Scaling Integration | Automatic integration with EC2 Auto Scaling |
| SSL/TLS Termination | Handle encryption at load balancer |
| CloudWatch Metrics | Performance monitoring |
| Access Log | Store request logs in S3 |
| Connection Draining | Remove instances after completing existing connections |
SAA-C03 Exam Focus Points
- ✅ ALB vs NLB selection: HTTP → ALB, TCP/UDP → NLB
- ✅ Static IP requirement: Only NLB supports static IP and Elastic IP
- ✅ Path-based routing: Only ALB supports
- ✅ Lambda targets: Only ALB supports
- ✅ GLB use case: Third-party security appliances
- ✅ CLB migration: ALB/NLB recommended for new deployments
Exam Tip
Sample Exam Question: "An application needs to route /api path traffic to API servers and /web path to web servers. What is the most appropriate solution?" → Answer: ALB path-based routing (NLB is L4 and cannot recognize URL paths)
Frequently Asked Questions
Q: Which is faster, ALB or NLB?
NLB is much faster. NLB operates at Layer 4, forwarding packets directly with ~100 microseconds latency. ALB parses HTTP at Layer 7, taking ~10 milliseconds.
Q: Can I use static IP with ALB?
Not directly. ALB only provides dynamic IPs. If you need static IPs, place NLB in front of ALB, or use Global Accelerator.
Q: Can I use ALB and NLB together on one load balancer?
Yes. NLB → ALB configuration lets you use both static IPs and L7 routing. This pattern is useful when combining PrivateLink with ALB.
Q: Which load balancer should I use for WebSocket?
Both support it. ALB natively supports WebSocket, and NLB handles it as TCP connections. NLB may be more suitable for long-lived connections.
Q: Can I continue using CLB?
Technically yes, but not recommended. AWS only adds new features to ALB/NLB and recommends migrating from CLB. The console provides a migration wizard.
Q: What is Cross-Zone Load Balancing?
A feature that distributes traffic evenly across all targets in all AZs. ALB has it enabled by default (free), NLB has it disabled by default (enabling incurs inter-AZ data transfer costs).
Related Posts
- Auto Scaling Group Setup and Policies
- Route 53 Routing Policies
- VPC Fundamentals: CIDR, Subnets, Route Tables