Elastic Load Balancing: ALB vs NLB
Part of the AWS Roadmap
In short
AWS gives you more than one kind of load balancer, and picking the wrong one means missing features or paying for ones you don't need. Most web apps want an ALB. Some need an NLB.
An Application Load Balancer works at layer 7 and routes HTTP and HTTPS by path, host or headers. A Network Load Balancer works at layer 4 for TCP, UDP and TLS with very high performance and static IPs. Gateway Load Balancers are for third-party network appliances.

Think of it like this
Mall receptionist vs toll plaza
The receptionist at a Hyderabad mall reads your question, 'food court or cinema?', and points you to the right floor. A highway toll plaza doesn't care where you're going. It just waves each vehicle into the next free lane, very fast. The ALB is the receptionist reading HTTP requests. The NLB is the toll plaza moving TCP and UDP traffic.
Watch it happen
Application vs Network Load Balancer
ALB (layer 7)
- HTTP, HTTPS, gRPC and WebSockets
- Routes by path, host, headers, query
- Targets: instances, IPs, Lambda
- Auth with Cognito or OIDC, WAF support
NLB (layer 4)
- TCP, UDP and TLS
- Handles very high throughput
- One static IP per AZ, or your Elastic IPs
- Preserves source IP, good for non-HTTP apps
Web apps and APIs: ALB. Game servers, IoT, very high connection counts, fixed IPs for a client's firewall, or non-HTTP protocols: NLB. Gateway Load Balancer is only for inline appliances like third-party firewalls.
The big ideas
What you need to know
Listener rules (ALB)
A listener on port 443 can send /api/* to one target group and admin.example.in to another.
TLS at the load balancer
Attach an ACM certificate to an HTTPS or TLS listener so targets don't need to manage certificates.
Static IPs (NLB)
NLB gives one fixed IP per AZ. ALB IPs change, so always use its DNS name or a Route 53 alias.
Security groups
ALBs always use security groups. NLBs can use them too if you attach them at creation time.
See it in code
Walk through the code
1# Send /api/* to the API target group, everything else to the web one2aws elbv2 create-rule \3 --listener-arn arn:aws:elasticloadbalancing:ap-south-1:111122223333:listener/app/shop-alb/abc/def \4 --priority 10 \5 --conditions Field=path-pattern,Values='/api/*' \6 --actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:111122223333:targetgroup/api-tg/1237 8# Redirect plain HTTP to HTTPS on the port 80 listener9aws elbv2 create-listener \10 --load-balancer-arn arn:aws:elasticloadbalancing:ap-south-1:111122223333:loadbalancer/app/shop-alb/abc \11 --protocol HTTP --port 80 \12 --default-actions '[{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","StatusCode":"HTTP_301"}}]'1/3Add a rule to the existing HTTPS listener. Priority 10 is checked before higher numbers.
AWS CLI v2. Rules are checked from the lowest priority number up. The listener's default action handles anything no rule matches.
Save yourself the pain
Common mistakes
Oops
Using an NLB for a normal website because 'it's faster'.
Do this instead
You'd lose path routing, redirects and WAF. An ALB handles most web traffic easily.
Oops
Hard-coding an ALB's IP address in DNS or a client's config.
Do this instead
ALB IPs change over time. Use its DNS name, a Route 53 alias, or an NLB if a fixed IP is truly required.
Your mission
Route two apps through one ALB
Quick check
A client's firewall only allows traffic to fixed IP addresses. Which load balancer fits?
Go deeper
- 1Create an ALB in two public subnets in front of two EC2 instances.
- 2Add a path-based rule that sends /api/* to a different target group.
- 3Write down when you would pick an NLB instead, such as for non-HTTP traffic or static IPs.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.