AWS Certified Solutions Architect – Associate
ALB vs NLB vs Gateway Load Balancer: which one to choose
Use an Application Load Balancer for HTTP and HTTPS routing by path, host or header. Use a Network Load Balancer for TCP, UDP or TLS traffic that needs static IP addresses and very high throughput. Use a Gateway Load Balancer to put third-party virtual appliances, such as firewalls, transparently in the traffic path.
Application Load Balancer (layer 7)
An ALB evaluates listener rules in priority order and can route on path, host header, HTTP headers, methods, query strings and source IP. It can redirect, return fixed responses, authenticate users and use Lambda functions as targets. It integrates with AWS WAF.
An ALB must be enabled in at least two Availability Zones. Cross-zone load balancing is always on at the load balancer level, though it can be turned off per target group. The default routing algorithm is round robin; least outstanding requests is the alternative.
Network Load Balancer (layer 4)
An NLB handles millions of requests per second. It gets a static IP address in each enabled Availability Zone, and you can attach one Elastic IP address per subnet, which suits partner allow-lists.
For TCP it uses a flow hash and keeps each connection on one target for the life of the connection. Target groups support TCP, UDP, TCP_UDP, TLS, QUIC and TCP_QUIC. Targets can be instances, IP addresses, or an Application Load Balancer.
Cross-zone load balancing is off by default on an NLB. With two targets in one zone and eight in another, each node keeps its 50% in its own zone, so the two targets get 25% each. Turning it on gives each of the ten targets 10%.
Gateway Load Balancer (layer 3)
A GWLB listens for all IP packets on all ports and sends them to virtual appliances such as firewalls, intrusion detection and prevention systems, and deep packet inspection systems. It exchanges traffic with the appliances using GENEVE on port 6081.
Traffic reaches it through Gateway Load Balancer endpoints, which you set as the next hop in route tables. Flows stick to one appliance (5-tuple by default). Health checks default to TCP on port 80; use HTTP or HTTPS with a path to test the appliance's own status page. Cross-zone load balancing is off by default.
Where the exam catches people
- Believing an ALB gives you fixed IP addresses: static and Elastic IP addresses per Availability Zone are a Network Load Balancer feature.
- Believing cross-zone load balancing is on by default everywhere: it is always on for ALBs but off by default for NLBs and GWLBs.
- Believing a GWLB inspects HTTP like an ALB: it works at layer 3, forwarding all IP packets to appliances over GENEVE on port 6081.
- Believing ALB sticky sessions pin TCP connections: cookies are HTTP stickiness; NLB keeps each TCP connection on one target by flow hash.
- Believing a GWLB health check reads the appliance's HTTP status by default: the default is a TCP check on port 80.