Skip to main content

02. AWS ELB

Elastic Load Balancing (ELB) automatically distributes incoming traffic across multiple EC2 instances (targets). It improves elasticity, availability, and fault tolerance.


Load Balancerโ€‹

  • Acts as a single entry point (DNS hostname).
  • Distributes requests across backend EC2 instances.
  • Performs health checks and removes unhealthy targets.
  • Supports SSL termination (HTTPS).
  • Enables multi-AZ high availability.

๐Ÿ—๏ธ Architectureโ€‹

Request Flow

User โ†’ Load Balancer โ†’ EC2 Instances (Targets)

  • Traffic is routed only to healthy instances.
  • Instances are spread across multiple AZs.
  • Scaling is automatic when used with Auto Scaling Groups.

โ˜ฏ๏ธ AWS-Managed vs Self-Managed Load Balancerโ€‹

TypeDescriptionManaged ByMaintenance EffortCost
AWS Managed ELBFully managed serviceAWSLowModerate
Self-Managed LB (on EC2)Custom setup on EC2YouHigh (OS, patching, scaling)Lower initially

๐Ÿงฑ OSI Model (7 Layers)โ€‹

  • Layer 7 โ€“ Application: HTTP, HTTPS, DNS
  • Layer 6 โ€“ Presentation: SSL/TLS, Encryption
  • Layer 5 โ€“ Session: Session control
  • Layer 4 โ€“ Transport: TCP, UDP
  • Layer 3 โ€“ Network: IP, Routing
  • Layer 2 โ€“ Data Link: MAC, Ethernet
  • Layer 1 โ€“ Physical: Cables, Signals

Mnemonic: All People Seem To Need Data Processing


๐ŸŒ Types of Load Balancers in AWSโ€‹

AWS provides four load balancer types:

Load BalancerLayerProtocolsKey FeaturesUse Case
Application Load Balancer (ALB)Layer 7HTTP, HTTPS, gRPCPath/host-based routingWeb apps, APIs
Network Load Balancer (NLB)Layer 4TCP, UDPUltra-high performance, static IPGaming, IoT, real-time apps
Gateway Load Balancer (GWLB)Layer 3IP (GENEVE)Traffic inspection & firewallingSecurity appliances
Classic Load Balancer (CLB) (deprecated)Layer 4 & 7TCP, HTTPLegacyโ€”

01. Application Load Balancer (ALB)โ€‹

  • Operates at Layer 7 (HTTP/HTTPS).
  • Supports advanced routing (host, path, headers, query).
  • Static DNS
  • Uses target groups.
  • Supports WebSockets and gRPC.
  • Provides a static DNS name (not static IP).

๐Ÿงฉ Architecture (ALB)โ€‹

Application Load Balancer architecture

๐Ÿ› ๏ธ Use Casesโ€‹

  • Web applications
  • REST APIs
  • Microservices (ECS, EKS)

02. Network Load Balancer (NLB)โ€‹

  • Operates at Layer 4 (TCP/UDP).
  • Handles millions of requests per second.
  • Supports static IPs using Elastic IPs.
  • Optimized for low latency.

๐Ÿงฉ Architecture (NLB)โ€‹

Network Load Balancer architecture

๐Ÿ› ๏ธ Use Casesโ€‹

  • Real-time systems
  • Gaming backends
  • Financial or IoT workloads

03. Gateway Load Balancer (GWLB)โ€‹

  • Operates at Layer 3 (IP).
  • Uses GENEVE (UDP port 6081).
  • Routes traffic through security appliances/firewall on EC2.
  • Enables centralized traffic inspection, intrusion detection or deep packet inspeciton.

๐Ÿงฉ Architecture (GWLB)โ€‹

Network Load Balancer architecture

๐Ÿ› ๏ธ Use Casesโ€‹

  • Firewalls
  • IDS / IPS systems
  • Deep packet inspection

04. Classic Load Balancer (CLB)โ€‹

โš ๏ธ Deprecated (do not use for new workloads)

  • Supports Layer 4 & 7.
  • Superseded by ALB and NLB.
  • Appears only in legacy architectures.

๐Ÿงฉ Comparison Summaryโ€‹

FeatureALBNLBGWLB
Layer743
ProtocolHTTP/HTTPS/gRPCTCP/UDPIP (GENEVE)
Routing LogicAdvancedConnection-basedPacket forwarding
Static IPโŒโœ…โœ…
SSL Terminationโœ…โœ…โŒ
Health ChecksHTTPTCPIP-based

๐Ÿงพ Exam Tips (CLF-C02)โ€‹

ScenarioChoose
HTTP / HTTPS routingALB
Millions of requests, ultra-low latencyNLB
Firewall or packet inspectionGWLB
Static IP requiredNLB
Legacy architectureCLB