AWS Builder Center
๐Ÿ“ˆ Day 13/30: Auto Scaling โ€” How Does AWS Automatically Add & Remove Servers? โ˜๏ธ

๐Ÿ“ˆ Day 13/30: Auto Scaling โ€” How Does AWS Automatically Add & Remove Servers? โ˜๏ธ

Discover how Auto Scaling helps our college examination portal handle sudden traffic spikes by automatically adjusting EC2 capacity. ๐Ÿš€ Learn about Auto Scaling Groups, scaling out and in, health checks, launch templates, and how Auto Scaling works with Load Balancers to keep applications reliable and efficient.

Series: Cloud Computing (24 articles)

  1. โ€ฆ
  2. 14
    ๐Ÿ“ˆ Day 13/30: Auto Scaling โ€” How Does AWS Automatically Add & Remove Servers? โ˜๏ธ This article
Tech Enthusiast | Exploring AWS, Data Structures & Web Dev

๐Ÿ“ˆ Day 13/30: Auto Scaling โ€” How Does AWS Automatically Add & Remove Servers? โ˜๏ธ

๐ŸŽฎ Mission 13: The Portal That Scales Itself!

Yesterday was crazy.
At 9:00 AM, thousands of students opened the college examination portal at the same time. ๐Ÿ˜ฑ
Our Load Balancer saved the day.
Instead of sending every request to one server, it distributed traffic across multiple EC2 instances.
Our architecture looked like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“
|
v
โš–๏ธ Load Balancer
|
+-----------+-----------+
| | |
v v v
EC2-1 EC2-2 EC2-3
| | |
+-----------+-----------+
|
v
Database
The portal survived.
Everyone could register.
Rahul smiled.
But at 2:00 PMโ€ฆ
The traffic dropped.
Now only a few students were using the portal.
And our college was still running all those EC2 servers.
Rahul asked:
โ€œWhy should we keep paying for servers we don't currently need?โ€
๐Ÿค”
Then the cloud architect smiled.
โ€œThat's exactly what Auto Scaling is designed to help with.โ€
Welcome to Day 13.
Today, we're teaching our cloud architecture how to adapt to changing demand automatically.

๐Ÿค– 1. What Is Auto Scaling?

In simple words:
Auto Scaling means automatically adjusting the number of compute resources according to demand and your scaling configuration.
Instead of manually doing this:
1
2
3
4
5
6
7
8
9
Traffic increases
โ†“
Admin notices
โ†“
Admin launches more servers
โ†“
Admin configures them
โ†“
Servers join application
We want something closer to:
1
2
3
4
5
6
7
8
9
Traffic increases
โ†“
Scaling policy triggers
โ†“
More EC2 instances launch
โ†“
Instances become healthy
โ†“
They can receive traffic
And when demand falls:
1
2
3
4
5
6
7
Traffic decreases
โ†“
Scaling policy triggers
โ†“
Extra instances are removed
โ†“
Application continues running
That's the basic idea behind Amazon EC2 Auto Scaling.

๐Ÿซ 2. Imagine Our College Has Smart Registration Counters

Let's return to our college.
Imagine there are registration counters.
At 8 AM:
1
2
3
4
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“
๐Ÿ‘จโ€๐ŸŽ“

2 counters are enough.
At 9 AM:
1
2
3
4
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“
๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“

We need more counters!
At 2 PM:
1
2
3
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“

We don't need all those counters anymore.
A smart college administration system could automatically open additional counters during busy periods and close unnecessary ones later.
That's the mental model for Auto Scaling.

๐Ÿงฉ 3. Meet the Auto Scaling Group

The main building block we'll use is an Auto Scaling Group (ASG).
Think of an Auto Scaling Group as a manager responsible for a group of EC2 instances.
It helps maintain the desired number of instances within configured limits.
For example:
1
2
3
Minimum capacity: 2
Desired capacity: 3
Maximum capacity: 6
This means our group is configured so that:
  • It should not normally go below 2 instances.
  • It currently wants 3 instances.
  • It should not automatically scale beyond 6 instances under that configuration.
So our application might begin like this:
1
2
3
4
5
6
Auto Scaling Group
|
+------------+------------+
| | |
v v v
EC2-1 EC2-2 EC2-3
Now traffic increases.
The scaling configuration determines that more capacity is needed.
The group can launch additional instances:
1
2
3
4
5
6
Auto Scaling Group
|
+-------+-------+-------+-------+
| | | | |
v v v v v
EC2-1 EC2-2 EC2-3 EC2-4 EC2-5
Our application has more compute capacity available.

๐ŸŽฏ 4. Desired, Minimum and Maximum Capacity

These three numbers are extremely important.
Let's say our college portal uses:
1
2
3
Minimum = 2
Desired = 3
Maximum = 6

๐ŸŸข Minimum Capacity

The minimum is the smallest number of instances the Auto Scaling Group should maintain under its configuration.
1
2
3
4
Minimum = 2

EC2-1
EC2-2

๐Ÿ”ต Desired Capacity

Desired capacity is the number of instances the group currently aims to maintain.
1
2
3
4
5
Desired = 3

EC2-1
EC2-2
EC2-3

๐Ÿ”ด Maximum Capacity

Maximum capacity places an upper boundary on automatic scaling.
1
2
3
4
5
6
7
8
Maximum = 6

EC2-1
EC2-2
EC2-3
EC2-4
EC2-5
EC2-6
So our cloud architecture has a controlled range:
1
2
3
4
Minimum Maximum
2 6
|------------------------------|
Capacity
This gives us control over both availability and resource usage.

๐Ÿš€ 5. What Happens When Traffic Suddenly Explodes?

It's Monday morning.
The college announces:
โ€œExamination registration closes today!โ€
Suddenly:
1
2
3
4
5
6
7
100 users
โ†“
1,000 users
โ†“
5,000 users
โ†“
20,000 users
The application needs more capacity.
Our architecture can respond according to its scaling configuration.
1
2
3
4
5
6
7
8
9
10
11
12
Students
|
v
โš–๏ธ Load Balancer
|
v
Auto Scaling Group
|
+---------+-------+-------+---------+
| | | | |
v v v v v
EC2-1 EC2-2 EC2-3 EC2-4 EC2-5
Now the workload can be distributed across more application instances.
The important idea is:
We don't need to manually launch every additional server.

๐Ÿ“‰ 6. What Happens When Traffic Falls?

Now it's midnight.
Most students are sleeping. ๐Ÿ˜ด
Only a few requests are coming in.
Keeping six EC2 instances running may provide capacity we don't currently need.
Our scaling policy can reduce the desired capacity, as long as it remains within the configured limits.
For example:
1
2
3
4
5
6
7
8
Before:

EC2-1
EC2-2
EC2-3
EC2-4
EC2-5
EC2-6
After scaling in:
1
2
3
EC2-1
EC2-2
EC2-3
The application still has capacity.
But we're no longer running as many instances as during the traffic spike.
This is called scaling in.

๐Ÿ“ˆ 7. Scaling Out vs Scaling In

These two terms are easy to remember.

๐Ÿ“ˆ Scaling Out

Add more instances.
1
2
3
3 EC2 instances
โ†“
5 EC2 instances
This is also called horizontal scaling.

๐Ÿ“‰ Scaling In

Remove instances.
1
2
3
5 EC2 instances
โ†“
3 EC2 instances
So:
Scale out = more instances
Scale in = fewer instances

๐Ÿง  8. Why Not Just Buy a Bigger Server?

Excellent question!
Suppose our college portal is running on one very powerful server.
Traffic increases.
We could replace it with an even larger server.
That's called vertical scaling.
1
2
3
4
5
Small Server
โ†“
Bigger Server
โ†“
Even Bigger Server
But there are limits.
Instead, cloud applications often use horizontal scaling:
1
2
3
4
5
One Server
โ†“
Multiple Servers
โ†“
More Servers
For many web applications, horizontal scaling provides flexibility and can improve resilience when combined with distributed architecture.
Our college portal can use multiple application instances rather than depending on one giant machine.

โค๏ธ 9. What If an EC2 Instance Suddenly Dies?

Now let's create a problem.
Our Auto Scaling Group has:
1
2
3
EC2-1 โœ…
EC2-2 โŒ
EC2-3 โœ…
EC2-2 crashes.
What should happen?
We don't want the application to permanently lose capacity.
An Auto Scaling Group can use health checks to determine whether instances are healthy.
If an instance is considered unhealthy, the group can terminate and replace it according to its configuration.
So the architecture can move toward:
1
2
3
4
5
Before:

EC2-1 โœ…
EC2-2 โŒ
EC2-3 โœ…
Then:
1
2
3
4
5
6
7
8
9
10
11
Auto Scaling Group
|
| Detects unhealthy instance
v
Replace EC2-2
|
v
Launch replacement
|
v
New healthy instance
Eventually:
1
2
3
EC2-1 โœ…
EC2-2 ๐Ÿ†•
EC2-3 โœ…
This is one of the powerful ideas behind cloud architecture:
The system can automatically recover capacity instead of waiting for a human to notice every failure.

โš–๏ธ 10. Auto Scaling + Load Balancer = Powerful Combination

Now let's connect yesterday's lesson with today's lesson.
Yesterday:
Load Balancer
โ€œI'll distribute traffic.โ€
Today:
Auto Scaling
โ€œI'll adjust the number of application instances.โ€
Together:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“
๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“
|
v
โš–๏ธ Load Balancer
|
v
๐Ÿ“ˆ Auto Scaling Group
|
+----------------+----------------+
| | |
v v v
EC2-1 EC2-2 EC2-3
| | |
+----------------+----------------+
|
v
Database
Now imagine traffic increases.
1
2
3
4
5
6
7
8
9
10
11
12
13
Traffic โ†‘
|
v
Auto Scaling
|
v
EC2-4 added
|
v
Load Balancer
|
v
New healthy target can receive traffic
Traffic decreases.
1
2
3
4
5
6
7
8
9
10
11
Traffic โ†“
|
v
Auto Scaling
|
v
Extra capacity removed
|
v
Load Balancer
continues serving remaining healthy targets
This is where our architecture starts becoming truly dynamic.

๐Ÿ—๏ธ 11. But How Does AWS Know How to Launch the Servers?

Here's another important piece.
If AWS needs to launch a new EC2 instance, it needs to know:
โ€œWhat kind of instance should I create?โ€
For example:
  • Which AMI?
  • Which instance type?
  • Which security groups?
  • Which IAM role?
  • Which subnets?
  • Which storage configuration?
  • Which user data or startup configuration?
Instead of manually configuring every instance, we can define the configuration used to launch instances.
A common approach is an EC2 launch template.
Think of it as a blueprint.
1
2
3
4
5
6
๐Ÿ“‹ Launch Template
|
+-----------+-----------+
| | |
v v v
EC2-1 EC2-2 EC2-3
Every new instance can be created using the defined configuration.
This helps make our servers more consistent.

๐ŸŒ 12. Spread the Servers Across Availability Zones

Remember our earlier lessons?
We don't want every application server sitting in one Availability Zone if our architecture requires resilience across zones.
Instead:
1
2
3
4
5
6
7
8
9
10
โš–๏ธ Load Balancer
|
+---------+---------+
| |
v v

Availability Zone 1 Availability Zone 2

EC2-1 EC2-3
EC2-2 EC2-4
Our Auto Scaling Group can be configured to launch instances across selected Availability Zones.
If one zone experiences a problem, the application may still have capacity in another zone, depending on the architecture and remaining resources.
This connects our entire journey:
Regions โ†’ Availability Zones โ†’ Load Balancing โ†’ Auto Scaling
Each concept solves a different part of the architecture problem.

๐Ÿ”ฅ 13. The College Portal Faces Its Biggest Challenge Yet

It's 8:55 AM.
The exam registration deadline is approaching.
Our system currently has:
1
2
3
Desired Capacity = 3
Minimum Capacity = 2
Maximum Capacity = 8
At 9:00 AM:
1
2
3
4
5
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“
๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽ“
โ†“
Traffic increases
Our architecture responds according to its scaling policy.
1
2
3
4
5
6
7
3 instances
โ†“
4 instances
โ†“
5 instances
โ†“
6 instances
The Load Balancer distributes traffic across healthy targets.
Students continue registering.
Rahul checks his screen.
1
โœ… Registration Successful
But this time, Rahul realizes something important:
The cloud architecture didn't just survive the traffic spike.
It adapted to it.

๐ŸŽฏ 14. A Simple Auto Scaling Story

Let's summarize the entire process.
1
2
3
4
5
6
7
8
9
10
11
12
13
1๏ธโƒฃ Users arrive
โ†“
2๏ธโƒฃ Load increases
โ†“
3๏ธโƒฃ Scaling policy detects the need for more capacity
โ†“
4๏ธโƒฃ Auto Scaling Group increases desired capacity
โ†“
5๏ธโƒฃ New EC2 instances launch from the configured template
โ†“
6๏ธโƒฃ Instances become healthy
โ†“
7๏ธโƒฃ Load Balancer sends traffic to healthy targets
And when demand drops:
1
2
3
4
5
6
7
8
9
1๏ธโƒฃ Traffic decreases
โ†“
2๏ธโƒฃ Scaling policy determines less capacity is needed
โ†“
3๏ธโƒฃ Auto Scaling Group decreases desired capacity
โ†“
4๏ธโƒฃ Extra instances are terminated
โ†“
5๏ธโƒฃ Remaining healthy instances continue serving users
That's the basic lifecycle.

๐Ÿงช 15. Cloud Architect Challenge

You are now the cloud architect for our college.
Your Auto Scaling Group is configured as:
1
2
3
Minimum = 2
Desired = 4
Maximum = 8

Scenario 1

Traffic suddenly increases.
Can the group launch more instances?
Yes, as long as the scaling policy calls for additional capacity and the configured maximum isn't exceeded.

Scenario 2

Traffic decreases significantly.
Can the group scale from 8 instances down to 2?
Potentially yes, depending on the scaling policy and current desired capacity, while respecting the configured minimum.

Scenario 3

One instance becomes unhealthy.
Can the Auto Scaling Group replace it?
Yes, when configured health checks identify it as unhealthy and the group takes corrective action.

Scenario 4

You want every new instance to have the same basic configuration.
What can help?
An EC2 launch template.

๐Ÿง  16. One Important Lesson: Auto Scaling Is Not Magic

Auto Scaling doesn't mean:
โ€œAWS will automatically make my application infinitely scalable.โ€
That's not how it works.
We still need to design the application properly.
For example:
  • ๐Ÿ—„๏ธ Can the database handle the increased traffic?
  • ๐Ÿ’พ Is application state stored appropriately?
  • ๐Ÿ” Are permissions correctly configured?
  • ๐ŸŒ Is the network designed correctly?
  • โš–๏ธ Is the load balancer configured correctly?
  • ๐Ÿ“ˆ Are scaling policies appropriate?
  • ๐Ÿ“Š Are we monitoring the system?
Adding more EC2 instances doesn't automatically solve every bottleneck.
For example:
1
2
3
4
5
6
7
100 EC2 instances
|
v
Tiny Database
|
v
๐Ÿ”ฅ DATABASE BOTTLENECK
The architecture must scale as a system.
That's what cloud architecture is really about.

๐Ÿงฉ 17. Look How Far Our Architecture Has Come

Remember Day 1?
We simply asked:
โ€œWhat is cloud computing?โ€
Now look at our architecture.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
๐Ÿ‘จโ€๐ŸŽ“ Students
|
v
๐ŸŒ Internet
|
v
โš–๏ธ Load Balancer
|
v
๐Ÿ“ˆ Auto Scaling Group
|
+----------------+----------------+
| | |
v v v
EC2-1 EC2-2 EC2-3
| | |
+----------------+----------------+
|
+-----------+-----------+
| |
v v
๐Ÿ—„๏ธ Amazon RDS ๐Ÿชฃ Amazon S3
Student Records Documents & Files
And behind this architecture we have already learned:
๐Ÿ” IAM โ†’ Who can access AWS resources?
๐ŸŒ VPC โ†’ How does traffic move through the cloud?
โš–๏ธ Load Balancer โ†’ Where should requests go?
๐Ÿ“ˆ Auto Scaling โ†’ How many application instances do we need?
๐Ÿ—„๏ธ Database โ†’ Where does application data live?
๐Ÿชฃ Storage โ†’ Where do files live?
This is no longer just a collection of AWS services.
It's becoming an architecture.

๐Ÿ† Mission Complete!

Today, our college portal learned how to adapt.
We started with a simple problem:
โ€œWhat happens when thousands of users arrive?โ€
And discovered:

โš–๏ธ Load Balancing

Distributes requests across application targets.

๐Ÿ“ˆ Auto Scaling

Adjusts application capacity according to scaling policies and configured limits.

๐Ÿ“‹ Launch Templates

Provide a repeatable configuration for launching EC2 instances.

โค๏ธ Health Checks

Help identify unhealthy instances so capacity can be maintained.

๐ŸŒ Multiple Availability Zones

Help distribute application capacity for greater resilience.
The result?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
TRAFFIC CHANGES
|
v
๐Ÿ“ˆ Auto Scaling
|
+------+------+
| |
v v
More EC2 Fewer EC2
when needed when needed
| |
+------+------+
|
v
โš–๏ธ Load Balancer
|
v
Users Happy ๐Ÿ˜Š

๐Ÿš€ Coming Up on Day 14/30

๐ŸŒŽ Content Delivery & CDN โ€” Why Does a Website Feel Faster When Content Is Closer to You?

Our college portal is now scalable.
But Rahul notices something strange.
The application works perfectly, yet students in another city are complaining:
โ€œThe portal is loading slowly!โ€
Why?
Because every image, CSS file, JavaScript file, and other static asset may have to travel a long distance to reach the user.
What if we could bring frequently requested content closer to users around the world? ๐ŸŒ
That's where our next mission begins.

Day 14 will explore:

  • ๐ŸŒŽ What is a Content Delivery Network?
  • โšก How does a CDN make websites faster?
  • ๐Ÿ“ฆ What is caching?
  • ๐Ÿš€ What is Amazon CloudFront?
  • ๐Ÿ—บ๏ธ How does content get served from locations closer to users?
  • ๐Ÿง  What should be cached โ€” and what should not?
  • ๐Ÿซ How can our college portal deliver images, CSS, JavaScript, and other static content faster?
Our architecture is about to move from:
โ€œHow do we handle more users?โ€
to:
โ€œHow do we serve those users faster?โ€
โ˜๏ธ Build it. Secure it. Scale it. Accelerate it.
#CloudComputing #AWS #CloudArchitecture #AutoScaling #AmazonEC2 #AWSCloud #30DaysOfCloud

Series: Cloud Computing (24 articles)

  1. โ€ฆ
  2. 14
    ๐Ÿ“ˆ Day 13/30: Auto Scaling โ€” How Does AWS Automatically Add & Remove Servers? โ˜๏ธ This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article