Study Guide820 words

Mastering AWS Elastic Load Balancing: Focus on Application Load Balancer (ALB)

Load balancing concepts (for example, Application Load Balancer [ALB])

Mastering AWS Elastic Load Balancing: Focus on Application Load Balancer (ALB)

Learning Objectives

After studying this guide, you should be able to:

  • Distinguish between the three modern types of AWS Elastic Load Balancers (ALB, NLB, GLB).
  • Explain how the Application Load Balancer operates at Layer 7 of the OSI model.
  • Configure routing rules based on paths, hostnames, and query strings.
  • Describe the integration between Elastic Load Balancing and EC2 Auto Scaling for high availability.
  • Implement health checks to ensure traffic is only routed to healthy targets.

Key Terms & Glossary

  • Listener: A process that checks for connection requests using a specific protocol and port.
  • Target Group: A logical grouping of targets (like EC2 instances or containers) to which the load balancer routes traffic.
  • Health Check: A periodic ping or request sent by the load balancer to a target to verify it is functioning correctly.
  • Layer 7 (Application Layer): The OSI layer that handles high-level protocols like HTTP and HTTPS, allowing for content-aware routing.
  • GENEVE Protocol: The protocol used by Gateway Load Balancers to encapsulate traffic for third-party virtual appliances.

The "Big Idea"

At its core, a load balancer is the single entry point for your application. Instead of users connecting directly to a single server, they connect to the load balancer. This decouples the client from the backend, allowing you to add or remove servers dynamically without the user ever knowing. It transforms a fragile, single-server setup into a resilient, scalable system that can survive instance failures and massive traffic spikes.

Formula / Concept Box

FeatureApplication Load Balancer (ALB)Network Load Balancer (NLB)Gateway Load Balancer (GLB)
OSI LayerLayer 7 (Application)Layer 4 (Transport)Layer 3 (Network)
ProtocolsHTTP, HTTPS, gRPCTCP, UDP, TLSGENEVE
Best ForWeb apps, MicroservicesExtreme performance, Static IPsFirewalls, Intrusion Detection
Routing LogicPath, Host, Query StringIP Protocol, PortIP Packets (Raw)

Hierarchical Outline

  1. Load Balancing Fundamentals
    • Entry Point: Users connect to a DNS name (Route 53) pointing to the LB.
    • Automation: Automatically updates when instances are added/removed.
  2. Modern Elastic Load Balancing (ELB) Types
    • Application Load Balancer (ALB): Content-based routing.
    • Network Load Balancer (NLB): High throughput, low latency.
    • Gateway Load Balancer (GLB): Third-party security appliances.
  3. Application Load Balancer Deep Dive
    • Listeners: Rules define how traffic is handled.
    • Target Groups: Routes to EC2, ECS, or IP addresses.
    • Routing Rules:
      • Path-based: example.com/images vs example.com/api.
      • Host-based: app1.example.com vs app2.example.com.
  4. Resiliency and Scalability
    • Auto Scaling Integration: ALB adds new instances to Target Groups automatically.
    • Cross-Zone Load Balancing: Distributes traffic across all Availability Zones.

Visual Anchors

Load Balancer Data Flow

Loading Diagram...

OSI Layer Positioning

\begin{tikzpicture}[node distance=1.5cm] \draw[thick] (0,0) rectangle (6,1) node[midway] {Layer 7: Application (ALB)}; \draw[thick] (0,-1.2) rectangle (6,-0.2) node[midway] {Layer 4: Transport (NLB)}; \draw[thick] (0,-2.4) rectangle (6,-1.4) node[midway] {Layer 3: Network (GLB)}; \draw[->, thick] (-1,0.5) -- (-1,-2.4) node[midway, left, rotate=90] {Deep Packet Inspection Levels}; \end{tikzpicture}

Definition-Example Pairs

  • Path-Based Routing: Routing requests to different target groups based on the URL path.
    • Example: Requests for example.com/video go to a cluster of optimized media servers, while example.com/images go to a different cluster.
  • Host-Based Routing: Routing requests based on the host field in the HTTP header.
    • Example: Routing orders.acme.com to one application and shipping.acme.com to another, even if they share the same load balancer.
  • Sticky Sessions (Affinity): Ensuring a client's requests are consistently sent to the same backend instance.
    • Example: A shopping cart application that stores session data locally on an EC2 instance (rather than a database) requires the user to stay on that specific instance during their session.

Worked Examples

Exercise: Deploying a Basic ALB

  1. Prepare Targets: Launch two EC2 instances in different subnets (AZ1 and AZ2). Install a simple web server (Apache) on both.
  2. Create Target Group:
    • Name: my-web-targets.
    • Target type: Instances.
    • Health check: HTTP on path /index.html.
  3. Configure ALB:
    • Name: my-application-lb.
    • Scheme: Internet-facing.
    • Listeners: Port 80 (HTTP).
    • Subnets: Select the subnets where your instances reside.
  4. Register Targets: Add your two EC2 instances to the my-web-targets group.
  5. Test: Copy the DNS name of the ALB and paste it into a browser. Refresh several times; you should see the response alternate between Server 1 and Server 2.

Checkpoint Questions

  1. Which load balancer type is best suited for an application requiring static IP addresses and handling millions of requests per second?
    • Answer: Network Load Balancer (NLB).
  2. A developer wants to route traffic to different microservices based on the URL path. Which ELB should they use?
    • Answer: Application Load Balancer (ALB).
  3. How does a load balancer know if an EC2 instance has crashed and should no longer receive traffic?
    • Answer: Through Health Checks; if the instance fails to respond to the ping/request, the LB marks it as unhealthy and stops routing traffic to it.
  4. What protocol does the Gateway Load Balancer use to communicate with virtual appliances?
    • Answer: The GENEVE protocol.

Ready to study AWS Certified Solutions Architect - Associate (SAA-C03)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free