Network Load Balancer
The layer 4 load balancer for TCP, UDP, TLS and QUIC, with static IPs per AZ, extreme performance, and instance, IP or ALB targets.
What it is
The Network Load Balancer (NLB) works at layer 4: it forwards TCP and UDP connections without looking inside the HTTP requests.
- Handles millions of requests per second with ultra-low latency, and absorbs sudden spikes.
- Listeners for TCP, TLS (secure TCP), UDP, TCP_UDP, and now QUIC.
- One static IP address per AZ, and the account's own Elastic IPs can be assigned to an internet-facing NLB. That's helpful when clients must allow-list specific IPs.
- Used for extreme performance, non-HTTP protocols (gaming, IoT, VoIP, databases), and anything needing static IPs.
Target groups
An NLB target group contains one kind of target:
- EC2 instances;
- IP addresses, which must be private IPs (instances, containers or on-premises servers);
- an Application Load Balancer: the NLB gives the static IPs, the ALB does the HTTP routing behind it.
Health checks can use TCP, HTTP or HTTPS, even when the traffic itself is TCP or UDP.
How traffic flows
- An NLB keeps each TCP connection (or UDP flow) on one target for its whole life, choosing by a hash of the source and destination addresses and ports.
- For instance targets, the target sees the client's real IP (client IP preservation), unlike with an ALB.
- With a TCP listener on port 443, traffic passes through still encrypted, so the targets decrypt it. With a TLS listener, the NLB terminates TLS itself.
- NLBs now support security groups, so instance security groups can reference the NLB's group, as with an ALB.
Updated since the slides
NLBs gained security groups in 2023 (before, client IPs had to be allowed on the targets), and they now support QUIC listeners for HTTP/3-style traffic. Cross-zone load balancing is still off by default for NLBs.
ALB or NLB?
- HTTP-aware routing, redirects, authentication, Lambda targets → ALB.
- TCP or UDP, extreme performance, static or Elastic IPs, client IP preserved → NLB.
- Both static IPs and HTTP routing → NLB in front of an ALB.
Exam tips
- "TCP / UDP traffic", "millions of requests per second", "ultra-low latency" → NLB.
- "Static IP address" or "Elastic IP" for a load balancer, "clients allow-list our IPs" → NLB.
- "Static IPs and path-based routing" → NLB with an ALB as the target (or Global Accelerator in front of an ALB).
- "End-to-end encryption, targets must decrypt" → NLB with a TCP listener on 443 (passthrough).
- "Gaming, VoIP, IoT over UDP" → NLB.
Common traps
- "Route by URL path on an NLB." NLBs don't read HTTP; use an ALB.
- "NLB targets can be Lambda functions." Lambda targets are for ALBs.
- "Target IPs can be public." IP targets must be private.
Check yourself
An NLB lab works like the ALB lab with the same cost, so instead of repeating it:
A Network Load Balancer with a UDP listener on 7777 and Elastic IPs assigned in each AZ.
An internet-facing NLB with Elastic IPs, whose target group is an Application Load Balancer that routes by path. (Global Accelerator in front of the ALB also works.)
An NLB with a TCP listener on port 443, so TLS passes through and the instances terminate it. (An ALB re-encrypting to HTTPS targets also keeps traffic encrypted, but the ALB decrypts it in between.)
AWS documentation
Application Load Balancer
The layer 7 load balancer for HTTP and HTTPS, with routing by path, host, headers and query string, target groups, and the X-Forwarded-For header.
Gateway Load Balancer
A layer 3 load balancer that sends all network traffic through a fleet of third-party virtual appliances such as firewalls, using GENEVE.