What is a Network Load Balancer (NLB)?
What you'll learn: How NLBs operate at Layer 4 to distribute TCP and UDP traffic with ultra-low latency and high throughput.
Understanding Layer 4 Load Balancing
A Network Load Balancer (NLB) works at the transport layer (OSI Layer 4), handling raw TCP and UDP connections. Unlike Application Load Balancers that inspect HTTP headers and URLs, NLBs simply route packets based on IP address and port number—making them extremely fast.
Think of it like a postal sorting facility that only reads zip codes (IP:port) versus one that opens every envelope to read the full address (HTTP headers). The zip-code-only approach is much faster.
TCP/UDP Traffic Distribution
NLBs excel at distributing:
- TCP traffic: Database connections, custom protocols, non-HTTP services
- UDP traffic: DNS queries, gaming protocols, streaming media
- Static IP requirements: NLBs can assign fixed Elastic IPs, critical for whitelisting
- Extreme performance: Millions of requests per second with microsecond latency
The NLB preserves the client's source IP address, forwarding it directly to targets—essential for logging and security rules that need to know the original requester.
When to Use NLBs Over ALBs
Choose an NLB when you need:
- Non-HTTP/HTTPS protocols (databases, custom TCP/UDP services)
- Maximum throughput and minimal latency
- Static IP addresses for your load balancer
- TLS passthrough (encryption handled by backend, not load balancer)
Choose an ALB when you need:
- HTTP/HTTPS routing based on paths, headers, or hostnames
- WebSocket or HTTP/2 support with content-aware decisions
- Request-level features like redirects or header modifications
Key Takeaway: Network Load Balancers operate at Layer 4 for ultra-fast TCP/UDP distribution with static IPs, while Application Load Balancers operate at Layer 7 for intelligent HTTP routing—pick based on your protocol and performance needs.