在打印窗口把「目标」选为「另存为 PDF」即可保存,页面已带 awsgood.com 版权水印。 返回原文

www.awsgood.com

Network Load Balancer vs Application Load Balancer: the difference

2026-11-10 AWS Comparison 约 3 分钟

TL;DR

The verdict: ALB, unless the protocol says otherwise

Application Load Balancer is the default answer for anything serving HTTP or HTTPS to browsers, mobile clients, or other services. Host and path routing, HTTP-status-aware health checks, per-target 5xx metrics, WAF attachment, and OIDC/Cognito auth at the listener are all bundled into the LCU price. Rebuilding that behind an NLB means running nginx or Envoy yourself and paying for the EC2 hours anyway.

Network Load Balancer is the correct answer in a much narrower band of cases: raw TCP or UDP, a client that pins your IP inside a firewall rule, TCP source-IP preservation for licensing or legacy allowlists, or an endpoint service consumed over PrivateLink. On a typical SMB account that's one workload in ten.

The migration direction matters too. Moving NLB → ALB is usually a DNS cutover with a 60-second TTL and a week of running both (about $16 of overlapping LB hours at list). Moving ALB → NLB means losing WAF, host routing, and every error-rate metric you've been alerting on.

The decision tree, in one table

Start at the protocol question and stop at the first row that matches.

Requirement Pick Why
HTTP/HTTPS, path or host routing to multiple services ALB Rules are free to add; each rule eval counts toward LCU
AWS WAF, Cognito/OIDC auth, fixed-response redirects ALB No WAF attachment point on NLB listeners
gRPC or WebSockets over HTTP/2 ALB End-to-end HTTP/2 on an HTTPS listener
Lambda targets (serverless backend) ALB NLB has no Lambda target type
Raw TCP, UDP, MQTT, syslog, SMTP, game traffic NLB ALB only speaks HTTP/HTTPS/gRPC
Client hardcodes an IP, or you need an EIP per AZ NLB One static IP per AZ; ALB node IPs rotate
TCP source IP must reach the target unchanged NLB ALB gives you X-Forwarded-For instead
Endpoint service for another VPC or account NLB PrivateLink requires NLB
Client IP allowlist at the app layer NLB, or ALB + Global Accelerator Accelerator gives static anycast IPs in front of ALB

Where the two really diverge in production

Dimension ALB NLB
Layer 7 (HTTP/HTTPS/gRPC/WebSocket) 4 (TCP/UDP/TLS)
Health checks HTTP path + status matcher, app-aware TCP port open by default; HTTP/HTTPS optional
Source IP at target ALB node IP + X-Forwarded-For Client IP preserved unchanged
Static IP No One EIP per AZ
Security groups Yes Yes, since 2023 (older guides say no)
WAF Attachable Not supported
Access logs Full request line, status, timings, ~every 5 min TLS/connection metadata only
CloudWatch

Sources