AWS in 1 Min · Episode 71

AWS Elastic Load Balancing explained

One front door, many servers. Watch the one-minute video, then read the details.

David Gomez1:18 video · 3 min read

"One big server can handle everything." Until it fails, and then everything is down at once. Several smaller servers are safer and easier to scale, but they create a new problem: users need one address, not a list of servers that changes every hour. Elastic Load Balancing (ELB) is the AWS service that solves it.

One front door, many targets

A load balancer is the single point of contact for clients. It accepts incoming traffic and distributes it across your registered targets: EC2 instances, containers, IP addresses and, for some types, Lambda functions.

You configure it with two building blocks:

  • A listener: the protocol and port the load balancer accepts connections on, for example HTTPS on 443.
  • A target group: the set of targets that receive the traffic, with the protocol and port to reach them.

Because clients only ever talk to the load balancer, you can add, remove or replace servers behind it without anyone noticing.

Health checks: skip what's broken

The load balancer regularly checks each target's health. When a target stops answering correctly, the load balancer stops sending it traffic, and starts again when the target recovers.

This is where a common mistake hides: a health check that only proves the web server process is up. If the page it checks returns "OK" while the application behind it can't reach its database, the load balancer keeps sending users to a broken server. Point the health check at a path that reflects whether the application can really serve requests.

Across Availability Zones

You enable the load balancer in several Availability Zones, and it routes to targets in each. If one zone fails, or simply has no healthy targets, traffic goes to the others. AWS recommends enabling multiple zones for every load balancer, and an Application Load Balancer requires at least two.

For this to help, you need targets in more than one zone. A load balancer in three zones with all the servers in one is still a single point of failure.

It scales itself, behind one DNS name

Elastic Load Balancing scales the load balancer as traffic changes; there is no size to choose. It gives you a DNS name, and the IP addresses behind that name can change as it scales. So point your domain at the name (in Route 53, with an alias record), never at an IP address you looked up once.

Better together with Auto Scaling

Attach a target group to an Auto Scaling group and the two cooperate: new instances are registered with the load balancer automatically, and instances being removed are deregistered and given time to finish in-flight requests. The Auto Scaling group can also use the load balancer's health checks to replace instances whose application has stopped answering.

Where AI fits

Model servers behind a load balancer behave differently from a typical web app. A response can take seconds, not milliseconds, and each server can only handle a few requests at once. With the default round robin algorithm, requests are handed out in turn, so a server that is already busy with long generations still gets the next one.

On an Application Load Balancer you can change the target group's routing algorithm to least outstanding requests, which sends each request to the target with the fewest requests in flight. Application Load Balancers also offer a newer feature, Target Optimizer, that enforces a maximum number of concurrent requests per target with the help of an agent on the targets; check the current documentation to see whether it fits your setup.

Quick recap

  • A load balancer is one front door for many targets.
  • Health checks take failing targets out of rotation.
  • It spans Availability Zones and scales itself; point your domain at its DNS name.
  • With Auto Scaling, targets register and deregister automatically.
AWS in 1 Min #71 · 1:18

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS