Network Load Balancer (NLB)
When to Use NLB?
What if you need a static IP?
If you need static IPs, consider:
- NLB (Network Load Balancer): Supports Elastic IPs, which are static
- You can put ALB behind NLB using AWS Global Accelerator for static IPs + HTTP/HTTPS support
NLB vs ALB Comparison
| Feature / Use Case | NLB (Network Load Balancer) | ALB (Application Load Balancer) |
|---|---|---|
| OSI Layer | Layer 4 (TCP, UDP, TLS) Transport | Layer 7 (HTTP, HTTPS, WebSocket) Application |
| Protocol Support | TCP, UDP, TLS | HTTP, HTTPS, WebSocket |
| Performance | Ultra-high performance; millions of requests/sec | High performance, but slightly lower than NLB |
| Latency | Ultra-low (suitable for real-time systems) | Slightly higher due to Layer 7 processing |
| Static IP Support | ✅ (Elastic IPs) | ❌ (uses dynamic IPs) |
| Preserve Client IP | ✅ | Only via X-Forwarded-For header |
| TLS Termination | ✅ | ✅ |
| Advanced Routing (URL path, host-based, headers, etc.) | ❌ | ✅ |
| WebSocket Support | ✅ (via TCP) | ✅ |
| Target Types | EC2, IP, ALBs | EC2, IP, Lambda |
| Use with PrivateLink | ✅ (required) | ❌ |
| AWS WAF Integration | ❌ | ✅ |
| Best For | Real-time apps, gaming, messaging, low-latency needs, private services | Web apps, microservices, API Gateway, advanced routing needs |
DNS Lookup Example
$ nslookup WebServer-nlb-5de2d39359116356.elb.us-east-1.amazonaws.comResources
Deploying AWS Elastic Load Balancers | ALB and NLB
