Your service must be reachable from outside its VPC. When would you put an AWS Network Load Balancer in front of it instead of an Application Load Balancer, and what do you give up by choosing NLB?
answer
- layer 4 flows versus layer 7 requests
- does routing need to read the request?
- non-HTTP protocols have only one option
- address versus hostname
- no WAF, no host or path rules
basics
~20 sNetwork Load Balancer is the right choice when traffic is not HTTP, when you need a fixed IP per Availability Zone, or when you need very high connection volume at minimal added latency. You give up HTTP-aware routing, WAF and authentication actions.
solid answer
~50 sNLB is a layer-4 load balancer: it forwards TCP, UDP and TLS flows without parsing the payload. I reach for it when the protocol is not HTTP (a game server on UDP, MQTT, a database proxy), when a partner or firewall needs a **static IP per Availability Zone** or an Elastic IP, when I need the client's source IP delivered to the target without relying on a header, or when the workload is millions of concurrent flows where the extra per-request processing of a layer-7 proxy is real cost. What I lose is everything that requires reading the request: host, path and header routing rules, redirect and fixed-response actions, OIDC authentication actions, `X-Forwarded-For` injection, and AWS WAF association, which attaches to ALB and CloudFront rather than to NLB. A common compromise is an NLB in front of an ALB — static IPs and PrivateLink at the edge, HTTP routing behind it.
go deeper
Be ready to say plainly that ALB handles HTTP and HTTPS while NLB handles TCP, UDP and TLS, and to name one workload for each.
Explain the mechanics behind the split: NLB forwards flows and never parses the payload, which is exactly why it supports non-HTTP protocols and offers a fixed address per subnet but no path or host routing.
Show the production judgment: pick the type from the real constraint — partner IP allowlist, PrivateLink, protocol, connection volume — and describe the NLB-in-front-of-ALB composition and what it costs you in hops and money.
Own the platform-wide tradeoff: a standard ingress shape everyone reuses beats per-team choices. Decide where WAF, TLS and authentication live once, and be explicit about the extra hop and dual charge that composition buys.
## Two different jobs Elastic Load Balancing is a family, not one product. The **Application Load Balancer (ALB)** operates at layer 7: it accepts an HTTP or HTTPS connection, parses each request, and decides where the request goes based on what is inside it. The **Network Load Balancer (NLB)** operates at layer 4: it sees a flow — a source address and port talking to a destination address and port — and forwards that flow to a target. It never parses a request, because at layer 4 there is no such thing as a request; there is only a connection carrying bytes. That single difference generates every practical consequence below. ## Where NLB wins **Non-HTTP protocols.** NLB listeners speak `TCP`, `UDP`, `TCP_UDP` and `TLS`. If the workload is a game server on UDP, a syslog collector, an MQTT broker, an SMTP relay or a database endpoint, ALB simply cannot front it. This is the most common reason an interview answer lands on NLB. **A stable address.** NLB provisions one IP address per enabled subnet, and you can supply your own Elastic IP for each subnet in the subnet mapping when you create the load balancer. Those addresses stay put for the life of the load balancer, which is what makes them allowlistable by a partner's firewall. ALB is addressed by DNS name only; the addresses behind that name are drawn from the AWS pool and change. **The client's source IP arrives natively.** Because NLB does not rewrite the source address for instance targets, the target's own socket reports the real client IP. A layer-7 proxy has to tell you the client address out of band, in a header. **Scale and latency profile.** NLB is designed for very high flow counts and adds very little latency, since it does no per-request work. For a service handling enormous connection volume, that is a measurable difference rather than a marketing line. **PrivateLink.** A VPC endpoint service — the provider side of AWS PrivateLink — is backed by a Network Load Balancer or a Gateway Load Balancer. If your service must be consumed privately from other VPCs or accounts, this alone can decide the load balancer type. ## What you give up Everything that requires understanding HTTP: - Listener rules that route on host, path, HTTP method, header or query string. - Redirect and fixed-response actions handled by the load balancer itself. - Built-in authentication actions that sit in front of your application. - `X-Forwarded-For` and the other forwarding headers a layer-7 proxy inserts. - AWS WAF association: WAF attaches to ALB, CloudFront and API Gateway, not to NLB. - Rich access logs. NLB access logs are produced only for TLS listeners, and describe TLS connections rather than HTTP requests, so "which URL was slow" is not a question an NLB log answers. ## The composite answer Senior answers rarely pick one. NLB targets can be an ALB, so a very common production shape is: NLB at the edge holding the Elastic IPs and the endpoint service, ALB behind it doing host and path routing, WAF on the ALB. You pay for two load balancers and add a hop, and in exchange you get static addressing and layer-7 features at the same time. ```bash # One NLB address per AZ, each pinned to an Elastic IP you already own aws elbv2 create-load-balancer \ --name payments-nlb --type network --scheme internet-facing \ --subnet-mappings \ SubnetId=subnet-0a1b2c3d,AllocationId=eipalloc-11111111 \ SubnetId=subnet-0e4f5a6b,AllocationId=eipalloc-22222222 ``` ## How to reason out loud Ask one question first: *does the routing decision need to see inside the request?* If yes, you want layer 7 and the conversation is about ALB. If no — and especially if the protocol is not HTTP at all, or the requirement is an address rather than a hostname — you want layer 4 and the conversation is about NLB. Both cost an hourly charge plus a capacity-unit charge, so cost is rarely the deciding factor; capability and addressing are.
- If you need static IPs but also host-based routing, what would you actually build?Put an NLB in front of an ALB: the NLB holds the Elastic IPs (and can back a PrivateLink endpoint service), and an ALB registered as its target does the host, path and header routing, with WAF attached to the ALB. You pay for two load balancers and one extra hop. AWS Global Accelerator is the alternative when you want static anycast addresses without the second load balancer.
- Can AWS WAF protect a workload that sits behind an NLB?Not on the NLB itself — WAF associates with Application Load Balancers, CloudFront distributions, API Gateway and a few other layer-7 surfaces. If the workload is HTTP and needs WAF, terminate HTTP on an ALB somewhere in the path, or put CloudFront in front. For genuinely non-HTTP traffic, your controls are network-layer ones: security groups, NACLs and AWS Shield.
- Which load balancer type is required to publish a service through AWS PrivateLink?A VPC endpoint service is fronted by a Network Load Balancer or a Gateway Load Balancer; an ALB cannot back one directly. If the service is HTTP and you want ALB routing, register the ALB as a target of the NLB and expose the NLB as the endpoint service.
saying these in an interview costs you the question
- Claims NLB can route by URL path if configured
- Says NLB is just a cheaper ALB
- Thinks NLB can have AWS WAF attached to it
- Assumes ALB supports UDP or arbitrary TCP
- Believes ALB also gives you a fixed IP address