2.1 Elastic Load Balancing (ELB) — ALB, NLB, and GWLB

Key Takeaways

  • Application Load Balancer (ALB) operates at Layer 7 (HTTP/HTTPS) and supports path-based routing, host-based routing, and WebSocket.
  • Network Load Balancer (NLB) operates at Layer 4 (TCP/UDP) and handles millions of requests per second with ultra-low latency and static IP addresses.
  • Gateway Load Balancer (GWLB) operates at Layer 3 and is used for deploying third-party virtual appliances (firewalls, IDS/IPS).
  • ALB is the default choice for web applications; NLB is for extreme performance, static IPs, or non-HTTP protocols.
  • Cross-zone load balancing distributes traffic evenly across all registered targets in all enabled AZs.
Last updated: March 2026

Elastic Load Balancing (ELB) — ALB, NLB, and GWLB

Quick Answer: Use ALB for HTTP/HTTPS web applications (Layer 7, content-based routing). Use NLB for extreme performance, static IPs, or non-HTTP protocols (Layer 4). Use GWLB for third-party virtual appliances. All ELBs support Multi-AZ for high availability.

ELB Overview

Elastic Load Balancing automatically distributes incoming traffic across multiple targets (EC2 instances, containers, IP addresses, Lambda functions) in one or more Availability Zones.

Why Load Balancers?

  • High availability — Distribute traffic across multiple AZs
  • Fault tolerance — Route traffic away from unhealthy targets
  • Scalability — Handle varying traffic loads automatically
  • Security — Terminate SSL/TLS at the load balancer
  • Decoupling — Frontend does not need to know about backend instances

Application Load Balancer (ALB)

The ALB operates at Layer 7 (application layer) and is the best choice for HTTP/HTTPS traffic.

ALB Features

FeatureDescription
Layer7 (HTTP/HTTPS)
RoutingPath-based (/api/, /images/), host-based (api.example.com), HTTP header/method, query string
TargetsEC2 instances, IP addresses, Lambda functions, containers (ECS)
SSL/TLSTerminate at ALB using ACM certificates
WebSocketNative support
HTTP/2Native support
Sticky sessionsDuration-based or application-based cookies
AuthenticationBuilt-in support for OIDC and Cognito
IP typeDynamic IPs (use DNS name, not IP)

ALB Routing Rules

Routing TypeExampleUse Case
Path-based/api/* → API target groupMicroservices
Host-basedapi.example.com → API TG; www.example.com → Web TGMulti-domain hosting
HTTP headerCustom-Header: mobile → Mobile TGA/B testing
Query string?platform=mobile → Mobile TGPlatform-specific routing
Source IP10.0.0.0/8 → Internal TGInternal vs. external

Network Load Balancer (NLB)

The NLB operates at Layer 4 (transport layer) and is designed for extreme performance.

NLB Features

FeatureDescription
Layer4 (TCP, UDP, TLS)
PerformanceMillions of requests/second, ultra-low latency (~100ms vs ~400ms for ALB)
Static IPOne static IP per AZ (can assign Elastic IP)
TargetsEC2 instances, IP addresses, ALB (can front an ALB)
SSL/TLSTLS termination supported
Source IP preservationPreserves client source IP
Health checksTCP, HTTP, HTTPS
ProtocolsTCP, UDP, TLS, TCP_UDP

When to Choose NLB

  • Need static IP addresses or Elastic IPs
  • Extreme performance (millions of requests/sec)
  • Non-HTTP protocols (gaming, IoT, custom TCP)
  • Need to preserve client source IP at the target
  • Need to front an ALB with a static IP (NLB → ALB pattern)

Gateway Load Balancer (GWLB)

The GWLB operates at Layer 3 (network layer) and is designed for deploying third-party virtual appliances.

FeatureDescription
Layer3 (IP packets)
Use CaseThird-party firewalls, IDS/IPS, deep packet inspection
ProtocolGENEVE encapsulation on port 6081
DeploymentTraffic flows through GWLB → appliance → back to GWLB
ScalingAutomatically scales appliance fleet

ELB Comparison

FeatureALBNLBGWLB
Layer7 (HTTP/HTTPS)4 (TCP/UDP)3 (IP)
Static IPNo (use DNS)YesYes
PerformanceGoodExtremeGood
RoutingContent-basedConnection-basedN/A
WAF supportYesNoNo
Lambda targetsYesNoNo
Use caseWeb apps, APIsExtreme perf, static IPNetwork appliances

Cross-Zone Load Balancing

BehaviorWithout Cross-ZoneWith Cross-Zone
Traffic distributionEven across AZs (not across instances)Even across ALL instances in all AZs
ALB defaultEnabled (always on, free)Enabled
NLB defaultDisabledCan enable (charges for inter-AZ data)

Health Checks

All ELB types perform health checks on registered targets:

  • Healthy threshold — Number of consecutive successes to mark healthy
  • Unhealthy threshold — Number of consecutive failures to mark unhealthy
  • Interval — Time between health checks
  • Unhealthy targets receive no traffic until they pass health checks again
Test Your Knowledge

A company needs a load balancer with a static IP address to allow clients to whitelist the IP. The application uses HTTPS. Which load balancer should they use?

A
B
C
D
Test Your Knowledge

A web application requires routing requests to different target groups based on the URL path (e.g., /api/* to one group, /images/* to another). Which load balancer supports this?

A
B
C
D
Test Your Knowledge

A company needs to deploy third-party firewall virtual appliances to inspect all traffic entering their VPC. Which load balancer type should they use?

A
B
C
D