Volume 2 · Chapter 7 — AWS Networking Deep Dive (VPC)
Elastic Load Balancing
7.1 Introduction
A load balancer is the front door of nearly every scalable, resilient application on AWS, and it’s where much of the networking in this volume comes together. It distributes incoming traffic across multiple targets in multiple Availability Zones, which is what makes horizontal scaling and multi-AZ resilience actually work. Understanding the load balancer types and what a load balancer provides - and doesn’t - is a frequent interview topic because it ties directly to availability, scaling, and health management.
7.2 What a Load Balancer Does
Elastic Load Balancing accepts incoming traffic and spreads it across a group of registered targets - EC2 instances, containers, or IPs - typically spanning several Availability Zones. It does three essential things. It distributes load so no single target is overwhelmed and so you can scale horizontally by adding targets. It performs health checks on its targets and stops sending traffic to any that are unhealthy, automatically routing around failures. And it spans multiple AZs, so the loss of a target or even a whole AZ simply means traffic goes to healthy targets elsewhere. This is the component that turns a pool of instances into a resilient, scalable service, and it works hand-in-hand with Auto Scaling, which adds and removes targets while the load balancer distributes to whatever is currently healthy.
flowchart TB
Internet((Users)) --> ALB[Application Load Balancer\nhealth checks + routing]
subgraph AZa[AZ A]
T1[Target 1 healthy]
T2[Target 2 unhealthy]
end
subgraph AZb[AZ B]
T3[Target 3 healthy]
T4[Target 4 healthy]
end
ALB --> T1
ALB -.x T2
ALB --> T3
ALB --> T4 7.3 The Load Balancer Types
AWS offers a few load balancer types for different needs. The Application Load Balancer (ALB) operates at the application layer (HTTP/HTTPS) and understands the content of requests, so it can route based on the URL path, host header, or other request attributes - ideal for web applications and microservices where you want path-based routing to different services, and it’s the most common choice. The Network Load Balancer (NLB) operates at the connection (TCP/UDP) layer, is extremely high-performance and low-latency, and handles enormous connection volumes - suited to non-HTTP traffic or ultra-high-throughput needs. (There’s also a Gateway Load Balancer for inserting network appliances like firewalls into the traffic path.) The practical rule: use an ALB for HTTP/HTTPS web and microservice traffic with content-based routing, and an NLB for extreme performance or non-HTTP protocols.
7.4 Health Checks and Cross-Zone Distribution
Health checks are central to what a load balancer provides. The load balancer periodically probes each target on a configured path or port; a target that fails is marked unhealthy and removed from rotation until it recovers, so users are never sent to a broken instance. This is what makes rolling deployments and instance replacement seamless - a new or restarting instance receives traffic only once it passes its health check. Cross-zone load balancing spreads requests evenly across targets in all AZs regardless of which AZ received the request, which prevents imbalance when zones have different numbers of targets. Health checks and multi-AZ target distribution are the properties that let a load-balanced service tolerate both individual target failures and whole-AZ failures without user impact.
7.5 Banking Production Scenario
A bank fronts its customer-facing application with an Application Load Balancer in public subnets across two Availability Zones. The ALB terminates TLS, routes requests by path to the appropriate microservices, and health-checks every target, removing any unhealthy instance from rotation automatically. Behind it, an Auto Scaling group runs application instances in private subnets across both AZs; as load rises at payday the group adds instances, which begin receiving traffic once healthy, and removes them afterwards. If an entire AZ fails, the ALB simply sends all traffic to the healthy targets in the surviving AZ, and the Auto Scaling group launches replacements. The load balancer is what makes the service both horizontally scalable and resilient to target and zone failures - the everyday backbone of the bank’s availability.
7.6 Troubleshooting: Load Balancer Problems
Load-balancer issues have familiar signatures. If all targets show unhealthy and traffic fails, the health check is usually misconfigured - wrong path, port, or protocol, or a security group that blocks the load balancer from reaching the target’s health-check port; the fix is aligning the health check and allowing the load balancer’s traffic to the targets. If traffic is uneven across instances, cross-zone load balancing or target distribution across AZs needs attention. If new deployments cause brief errors, targets may be receiving traffic before they’re ready - the fix is a correct health check and connection draining so in-flight requests finish before an instance is removed. If HTTPS fails, it’s typically a certificate issue at the listener. The diagnostic pattern is to check target health status first (it tells you immediately whether the LB considers targets usable), then the health-check and security-group configuration, then the listener and routing rules.
What does a load balancer provide, and what's the difference between an Application and a Network Load Balancer?
A load balancer is the component that distributes incoming traffic across multiple targets - instances, containers, or IPs - typically spanning several Availability Zones, and it’s what makes horizontal scaling and multi-AZ resilience actually work. It provides three essential things. First, load distribution: it spreads requests across a pool of targets so none is overwhelmed and so you can scale out by adding more targets behind it. Second, health checking: it continuously probes its targets and stops sending traffic to any that are unhealthy, automatically routing around failed instances so users never hit a broken one - which is also what makes rolling deployments and instance replacement seamless, since a target receives traffic only once it passes its health check. Third, multi-AZ distribution: because it spans Availability Zones, the loss of a target or even an entire AZ just means traffic flows to healthy targets elsewhere. It works hand-in-hand with Auto Scaling, which adds and removes instances while the load balancer distributes to whatever is currently healthy. On the types: an Application Load Balancer operates at the application layer - HTTP and HTTPS - and understands the content of requests, so it can route based on the URL path, host header, or other attributes; that content awareness makes it ideal for web applications and microservices where you want, say, path-based routing to different backend services, and it’s the most common choice for web traffic. A Network Load Balancer operates at the connection layer - TCP and UDP - and is built for extreme performance, very low latency, and huge connection volumes; it doesn’t inspect application content, so you choose it for non-HTTP protocols or when you need ultra-high throughput and minimal latency. There’s also a Gateway Load Balancer for inserting network appliances like firewalls into the path, but the main decision is ALB versus NLB. The rule I apply is: use an Application Load Balancer for HTTP/HTTPS web and microservice traffic where content-based routing helps, and a Network Load Balancer for extreme performance or non-HTTP protocols. So a load balancer gives you distribution, health-based routing, and multi-AZ resilience, and the ALB-versus-NLB choice comes down to whether you need application-layer, content-aware routing or connection-layer, maximum-performance handling.
Chapter Revision Notes
- A load balancer distributes traffic across targets in multiple AZs, health-checks them, and routes around failures - enabling scaling and resilience.
- It works with Auto Scaling: instances are added/removed while the LB sends traffic only to currently-healthy targets.
- Application Load Balancer: HTTP/HTTPS, content-aware routing (path/host) - the common choice for web and microservices.
- Network Load Balancer: TCP/UDP, ultra-high performance and low latency - for non-HTTP or extreme throughput.
- Health checks and cross-zone distribution let a service tolerate target and whole-AZ failures; diagnose from target health status first.