Selecting the Appropriate AWS Load Balancing Strategy: A Comprehensive Study Guide
Selecting the appropriate load balancing strategy
Selecting the Appropriate AWS Load Balancing Strategy
This guide explores the mechanisms AWS provides to distribute incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, and IP addresses. Understanding the nuances between different load balancer types and routing policies is critical for designing highly available, scalable, and fault-tolerant architectures.
Learning Objectives
- Differentiate between the three modern Elastic Load Balancing (ELB) types: Application, Network, and Gateway.
- Map specific protocol requirements (HTTP, TCP, UDP) to the appropriate load balancer.
- Identify use cases for Layer 7 versus Layer 4 routing.
- Evaluate Route 53 routing policies (Weighted, Latency, Failover) for multi-region or complex traffic scenarios.
- Design a strategy for integrating third-party virtual appliances into a VPC using Gateway Load Balancers.
Key Terms & Glossary
- OSI Model: A conceptual framework used to understand network interactions in seven layers. Load balancers primarily operate at Layers 3, 4, and 7.
- Target Group: A logical grouping of targets (EC2 instances, Lambda functions, or IP addresses) that receive requests from a load balancer.
- Health Check: A periodic ping sent by the load balancer to targets to ensure they are responding. If a target fails, the balancer stops sending traffic to it.
- GENEVE Protocol: A network virtualization protocol used by Gateway Load Balancers to wrap original packets for inspection by virtual appliances.
- Listener: A process that checks for connection requests using a configured protocol and port.
The "Big Idea"
The core purpose of load balancing is Decoupling. By placing a load balancer between your users and your servers, you create a "buffer" that allows you to add or remove resources (scaling) and handle server failures (availability) without the customer ever knowing the underlying infrastructure has changed. The load balancer becomes the single, stable entry point for the application.
Formula / Concept Box
| Feature | Application Load Balancer (ALB) | Network Load Balancer (NLB) | Gateway Load Balancer (GLB) |
|---|---|---|---|
| OSI Layer | Layer 7 (Application) | Layer 4 (Transport) | Layer 3 (Network) |
| Protocols | HTTP, HTTPS, gRPC | TCP, UDP, TLS | IP, GENEVE |
| Key Metric | Requests per second | Connections per second | Packets per second |
| Best For | Microservices, Path-based routing | Extreme performance, Static IPs | Firewalls, Intrusion Detection |
| Static IP? | No (uses DNS name) | Yes (Elastic IP supported) | No |
Hierarchical Outline
- Elastic Load Balancing (ELB) Fundamentals
- Automation: Scales automatically to handle traffic spikes.
- Health Monitoring: Routes traffic only to healthy instances.
- Modern Balancer Types
- Application Load Balancer (ALB): Content-based routing.
- Path-based: Route
/apito one group and/imagesto another. - Host-based: Route
example.comvsdev.example.com.
- Path-based: Route
- Network Load Balancer (NLB): High performance.
- Capable of handling millions of requests per second with ultra-low latency.
- Preserves client-side source IP address.
- Gateway Load Balancer (GLB): Third-party appliance management.
- Simplifies deployment of virtual firewalls and Deep Packet Inspection (DPI) tools.
- Application Load Balancer (ALB): Content-based routing.
- Amazon Route 53 Routing Policies
- Simple: One-to-one mapping.
- Weighted: Split traffic by percentage (e.g., Canary testing).
- Latency-based: Route to the region with the fastest response time.
- Failover: Active-Passive setup for disaster recovery.
Visual Anchors
Traffic Flow Architecture
OSI Layer Mapping
\begin{tikzpicture}[node distance=1.5cm] \draw[thick] (0,4) rectangle (6,5) node[midway] {Layer 7: Application (ALB)}; \draw[thick] (0,2.5) rectangle (6,3.5) node[midway] {Layer 4: Transport (NLB)}; \draw[thick] (0,1) rectangle (6,2) node[midway] {Layer 3: Network (GLB)};
\draw[->, thick] (-1,0.5) -- (-1,5.5) node[midway, left, rotate=90] {Abstraction Level};
\draw[->, thick] (7,5.5) -- (7,0.5) node[midway, right, rotate=-90] {Performance/Throughput};\end{tikzpicture}
Definition-Example Pairs
- Path-Based Routing: Routing requests based on the URL path.
- Example: A travel site routes
example.com/flightsto a compute-optimized fleet andexample.com/imagesto a storage-optimized fleet.
- Example: A travel site routes
- Sticky Sessions (Session Affinity): Ensuring a user is consistently routed to the same backend server for the duration of their session.
- Example: An older e-commerce app that stores shopping cart data in local server memory (RAM) rather than a database requires sticky sessions to prevent the cart from "disappearing."
- Weighted Routing: Assigning weights to resource records to determine what portion of traffic goes to which resource.
- Example: During a new software release, you assign a weight of 10 to a new version and 90 to the old version to test the new code on 10% of real users (Canary deployment).
Worked Examples
Scenario 1: The High-Volume Stock Trading App
Problem: A company is building a stock trading platform that requires ultra-low latency and must handle millions of concurrent TCP connections. They also need to provide a single, static IP address to their partners for firewall whitelisting.
Solution:
- Select Load Balancer: Use a Network Load Balancer (NLB).
- Reasoning: NLBs operate at Layer 4, providing the lowest latency. Unlike ALBs, NLBs can be assigned Elastic IPs, providing a fixed entry point for partners.
- Configuration: Define a TCP listener on port 443 and register the trading engine EC2 instances in a Target Group.
Scenario 2: Regional Disaster Recovery
Problem: A global enterprise wants to ensure that if their primary AWS region (us-east-1) goes down, traffic is automatically diverted to their backup region (us-west-2).
Solution:
- Service: Use Amazon Route 53.
- Policy: Implement a Failover Routing Policy.
- Steps:
- Create a Primary record pointing to the us-east-1 load balancer.
- Create a Secondary record pointing to the us-west-2 load balancer.
- Configure Route 53 Health Checks on the Primary record. If the health check fails, Route 53 automatically starts resolving the domain to the Secondary record.
Checkpoint Questions
- Which load balancer should you choose if you need to route traffic based on the 'User-Agent' header in an HTTP request?
- You are managing a fleet of third-party firewalls in a centralized VPC. Which AWS service allows you to scale these appliances and present them as a single endpoint to other VPCs?
- What is the main difference between Latency-based routing and Geolocation routing in Route 53?
- True or False: A Network Load Balancer is the best choice for an application that requires path-based routing for microservices.
- How does a load balancer handle a target instance that becomes unhealthy?
▶Click to see answers
- Application Load Balancer (ALB) - because it operates at Layer 7 and can inspect HTTP headers.
- Gateway Load Balancer (GLB).
- Latency routing directs users to the region with the lowest network delay, while Geolocation routing directs users based on their actual physical location (e.g., all users in France go to the Europe region).
- False. Path-based routing is a Layer 7 feature, making ALB the correct choice.
- It stops sending new requests to that instance and redirects traffic to the remaining healthy targets in the group.