0Pricing
AWS Solutions Architect · Lesson

ALB vs NLB vs GLB: When to Use Which

Understand the differences between Application, Network, and Gateway Load Balancers and match each to its ideal use case.

ALB vs NLB vs GLB: When to Use Which is a free AWS Solutions Architect lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Elastic Load Balancing Overview

Elastic Load Balancing (ELB) automatically distributes incoming application traffic across multiple targets—EC2 instances, containers, Lambda functions, or IP addresses. ELB is a managed service, meaning AWS handles provisioning, scaling, and availability of the load balancer itself across multiple AZs.

AWS offers three types of load balancers under the ELB umbrella: Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB). Each operates at a different layer of the OSI model and is optimised for different use cases.

Application Load Balancer (ALB)

The ALB operates at Layer 7 (HTTP/HTTPS) of the OSI model. It can inspect HTTP headers, paths, query strings, hostnames, and cookies to make intelligent routing decisions. ALB is the go-to choice for web applications, microservices, and API endpoints that need content-based routing.

Key ALB features: path-based routing (/api/* to one target group, /static/* to another), host-based routing (different virtual hosts to different backends), HTTP header and query string routing, WebSocket support, and HTTP/2 support. ALB can route to EC2 instances, containers (ECS/EKS), Lambda functions, and IP addresses.

# Create an ALB
aws elbv2 create-load-balancer \
  --name my-alb \
  --subnets subnet-aaaa1111 subnet-bbbb2222 \
  --security-groups sg-12345678 \
  --type application

Network Load Balancer (NLB)

The NLB operates at Layer 4 (TCP/UDP/TLS). It routes packets based on IP protocol data without inspecting application content. NLB is designed for extreme performance: it handles millions of requests per second with ultra-low latency (typically under 100 microseconds).

Key NLB features: static IP addresses per AZ (one Elastic IP per subnet), TLS pass-through (forward encrypted traffic without decrypting), preservation of the client IP address, and support for UDP protocols (e.g., DNS, RADIUS, game servers). NLB cannot perform content-based routing or inspect HTTP headers.

# Create an NLB
aws elbv2 create-load-balancer \
  --name my-nlb \
  --subnets subnet-aaaa1111 subnet-bbbb2222 \
  --type network

Gateway Load Balancer (GWLB)

The GWLB operates at Layer 3 (network layer) and is designed exclusively for deploying, scaling, and managing third-party virtual network appliances—firewalls, intrusion detection and prevention systems (IDS/IPS), and deep packet inspection systems.

GWLB uses the GENEVE protocol (port 6081) to encapsulate traffic and send it to your appliance fleet. The appliance inspects the packet and returns it through the same GWLB endpoint. Traffic flows transparently without requiring routing changes in the source VPC. This is the standard pattern for inserting centralised security inspection into AWS VPC traffic flows.

ALB Use Cases

Choose ALB when:

  • You need HTTP/HTTPS content-based routing (path, host, header, query string)
  • Your backend includes Lambda functions or ECS containers
  • You need WebSocket or HTTP/2 connections
  • You want to integrate with AWS WAF for web application security at the load balancer layer
  • You are building a microservices architecture with many services on different URL paths
  • You need SSL/TLS termination at the load balancer

ALB is the correct answer for most web application and REST API load balancing questions on the SAA-C03 exam.

NLB Use Cases

Choose NLB when:

  • You need extreme performance (millions of requests per second, sub-millisecond latency)
  • You require static IP addresses that partners or firewalls can allowlist
  • You need to handle UDP traffic (gaming, DNS, RADIUS, IoT)
  • You want TLS pass-through without decrypting at the load balancer (end-to-end encryption to the target)
  • You need to preserve the client source IP natively at the TCP level
  • You are using AWS PrivateLink to expose services to other VPCs or accounts (NLB is required for PrivateLink)

GWLB Use Cases and Architecture

Choose GWLB when you need to:

  • Insert third-party firewall appliances (Palo Alto, Fortinet, Check Point) into your network traffic flow
  • Perform deep packet inspection at the VPC level for all inbound or outbound traffic
  • Scale a fleet of IDS/IPS appliances horizontally with automatic load balancing

Architecture: Traffic flows from source VPC → GWLB endpoint → appliance VPC (where GWLB distributes traffic across appliance instances) → appliance returns traffic to GWLB → GWLB forwards to original destination. The source and destination are unaware of the inspection in between.

Cross-Zone Load Balancing

Cross-zone load balancing distributes traffic evenly across all registered targets in all enabled AZs, regardless of which AZ the load balancer node received the request in. Without cross-zone load balancing, each AZ's node only distributes traffic to targets in its own AZ.

ALB has cross-zone load balancing enabled by default at no extra cost. NLB has cross-zone load balancing disabled by default—enabling it incurs inter-AZ data transfer charges. GWLB has cross-zone load balancing disabled by default. Enable cross-zone LB when target counts are uneven across AZs to avoid hot spots.

Comparing Protocols and Features

Quick comparison table for the exam:

  • OSI Layer: ALB = 7 (HTTP), NLB = 4 (TCP/UDP), GWLB = 3 (IP)
  • Protocols: ALB = HTTP, HTTPS, WebSocket; NLB = TCP, UDP, TLS; GWLB = all IP protocols via GENEVE
  • Static IP: ALB = No (use NLB + ALB pattern); NLB = Yes (1 per AZ); GWLB = N/A
  • WAF integration: ALB = Yes; NLB = No; GWLB = No
  • Lambda target: ALB = Yes; NLB = No; GWLB = No
  • Connection draining: all three support deregistration delay

ALB with AWS WAF

ALB integrates natively with AWS WAF for regional protection (as opposed to WAF on CloudFront for global edge protection). By attaching a WAF Web ACL to an ALB, you can filter HTTP requests before they reach your application—blocking SQL injection, XSS, known malicious IPs, and rate-abusing clients.

Use ALB + WAF when you want security inspection at the load balancer layer (e.g., to protect APIs that are not served through CloudFront). WAF Web ACLs attached to ALBs must be in the same Region as the ALB and must have REGIONAL scope (unlike CloudFront WAF which requires CLOUDFRONT scope in us-east-1).

NLB with PrivateLink

AWS PrivateLink uses NLB to expose services in one VPC to consumers in other VPCs or AWS accounts without requiring VPC peering, an internet gateway, or NAT. The service provider creates an NLB in front of their service and creates a VPC Endpoint Service. Consumers create an Interface VPC Endpoint in their VPC that points to the service.

Traffic flows over AWS's private network, never traversing the internet. PrivateLink is the standard pattern for SaaS providers on AWS and for exposing shared services (e.g., a centralised security service) to multiple internal AWS accounts.

Quick Check

Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.

Lesson Recap

In this lesson you learned: ALB routes at Layer 7 (HTTP) with content-based rules, WAF integration, and Lambda targets, NLB routes at Layer 4 (TCP/UDP) with static IPs and extreme throughput, and GWLB deploys virtual network appliances at Layer 3 using GENEVE. Match the load balancer to the protocol and feature requirements. Next up we explore target groups and health checks.

Frequently asked questions

Is the “ALB vs NLB vs GLB: When to Use Which” lesson free?

Yes — the full text of “ALB vs NLB vs GLB: When to Use Which” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.

What will I learn in “ALB vs NLB vs GLB: When to Use Which”?

Understand the differences between Application, Network, and Gateway Load Balancers and match each to its ideal use case. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Solutions Architect?

No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “ALB vs NLB vs GLB: When to Use Which” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Solutions Architect lesson?

Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. ALB vs NLB vs GLB: When to Use Which
  2. Target Groups and Health Checks
  3. Listener Rules and Path-Based Routing
  4. SSL Termination and Sticky Sessions
← Back to AWS Solutions Architect