Copyright (c) 2025 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

2.2.1.2. Load Balancing Concepts: ALB, NLB

šŸ’” First Principle: Load balancing distributes incoming application traffic across multiple targets, enhancing availability, fault tolerance, and scalability.

Load balancing is crucial for distributing network traffic evenly across a group of backend resources (e.g., EC2 instances, containers, Lambda functions). This prevents any single resource from becoming a bottleneck, improving performance, availability, and resilience. Elastic Load Balancing (ELB) is the AWS service that provides this functionality.

  • Application Load Balancer (ALB): Operates at Layer 7 of the OSI model, the application layer (HTTP/HTTPS). Ideal for web applications, supporting advanced routing (e.g., path-based, host-based, sticky sessions) and content-based routing. Use for intelligent routing based on application-layer content.
  • Network Load Balancer (NLB): Operates at Layer 4 of the OSI model, the transport layer (TCP/UDP). Designed for extreme performance, static IP addresses, and ultra-low latency. Best for non-HTTP/HTTPS traffic or when preserving client IP is critical.
Key Load Balancing Concepts:
  • Traffic Distribution: Spreads load across targets.
  • Health Checks: Routes traffic only to healthy targets.
  • "ALB": Layer 7, HTTP/S, smart routing.
  • "NLB": Layer 4, TCP/UDP, high performance, static IPs.

Scenario: An Application Load Balancer (ALB) efficiently routes incoming HTTP/HTTPS requests for a web application across a dynamic fleet of Amazon EC2 instances, ensuring consistent performance and high availability.

Visual: ALB vs. NLB
Loading diagram...

āš ļø Common Pitfall: Using an NLB when you need advanced Layer 7 routing features like path-based routing or SSL offloading. The NLB is simpler but lacks these application-level capabilities.

Key Trade-Offs:
  • Features (ALB) vs. Raw Performance (NLB): ALB provides intelligent, application-level routing and features. NLB prioritizes extreme performance and static IPs for network-level traffic.

Reflection Question: How does strategically choosing between an ALB (Layer 7) and an NLB (Layer 4) impact an application's resilience and performance under varying traffic patterns and protocol requirements?