Making Applications Elastic with Auto Scaling and Load Balancing
This lesson explains how Amazon EC2 Auto Scaling and Elastic Load Balancing work together to make applications elastic, fault tolerant and highly available.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how Amazon EC2 Auto Scaling adjusts the number of instances to demand.
- Describe how Elastic Load Balancing spreads traffic across healthy targets.
- Explain how the two services together keep an application available when an Availability Zone fails.
Amazon EC2 Auto Scaling
Amazon EC2 Auto Scaling adjusts the number of instances to match demand. The following list describes how it works.
- Automatically launches or terminates instances to keep the right number running, between a minimum, maximum and desired capacity.
- Scales on demand (e.g. average CPU at 50%), on a schedule (e.g. business hours) or by prediction, giving elasticity and saving money.
- Runs health checks and replaces unhealthy instances, improving fault tolerance.
EC2 Auto Scaling
Elastic Load Balancing (ELB)
Elastic Load Balancing spreads incoming traffic across several targets, such as EC2 instances, containers, IP addresses or Lambda functions, in several Availability Zones. It sends traffic only to targets that pass health checks, so the application keeps working when one fails. There are three types. An Application Load Balancer understands web traffic (HTTP and HTTPS) and can route requests by their URL path or host name, which suits web applications and microservices. A Network Load Balancer handles TCP and UDP traffic with extreme performance and static IP addresses. A Gateway Load Balancer sends traffic through third-party virtual appliances, such as firewalls. The following table summarises the types.
| Load balancer | Layer | Use for |
|---|---|---|
| Application Load Balancer | 7 (HTTP, HTTPS) | Web apps and microservices; routes by URL path or host name |
| Network Load Balancer | 4 (TCP, UDP) | Extreme performance and static IP addresses |
| Gateway Load Balancer | 3 | Third-party virtual appliances such as firewalls |
Which load balancer?
A highly available architecture
An Application Load Balancer in front of an Auto Scaling group spanning several Availability Zones. If an instance, or a whole AZ, fails, traffic flows to healthy instances and Auto Scaling replaces the lost capacity.
The following diagram shows a load balancer in front of an Auto Scaling group across three AZs.

A website that heals and scales itself
A news site runs on EC2 instances in an Auto Scaling group across three Availability Zones, behind an Application Load Balancer. The group is set to a minimum of 3, desired 3 and maximum 15 instances, with a policy to keep average CPU around 50%. Here is what happens on a big news day:
| Time | Event | What AWS does |
|---|---|---|
| 09:00 | Normal traffic | 3 instances, one per AZ; the load balancer spreads requests |
| 11:30 | Breaking news; CPU rises to 85% | Auto Scaling launches instances up to 12; the load balancer starts sending them traffic |
| 13:00 | One instance crashes | Health checks fail; the load balancer stops sending it traffic; Auto Scaling replaces it |
| 18:00 | Traffic falls | Auto Scaling removes instances back to 3, so the company stops paying for them |
Load balancing provides availability and spreads the load; Auto Scaling provides elasticity and replaces failed instances. Together across several AZs they make the site highly available and cost effective.
What does Elastic Load Balancing do?
Show answer
It spreads incoming traffic across healthy targets, such as EC2 instances in several Availability Zones.
Exam Tips
Remember for the exam
- To add or remove instances automatically with demand, use EC2 Auto Scaling.
- Unhealthy instances are replaced automatically by Auto Scaling health checks.
- To distribute traffic across instances and Availability Zones, use Elastic Load Balancing.
- Web traffic routed by URL path calls for an Application Load Balancer.
- Very high-performance TCP or UDP traffic calls for a Network Load Balancer.
- High availability comes from a load balancer and Auto Scaling across several Availability Zones.