DEV Community

Naoki
Naoki

Posted on

What Is AWS Auto Scaling? A Simple Guide to EC2 Auto Scaling Groups

What Is AWS Auto Scaling? A Simple Guide to EC2 Auto Scaling Groups

To put it simply, setting up basic Auto Scaling isn't that difficult.

In the AWS Management Console, you configure:

  • What kind of EC2 instances to launch
  • The minimum, desired, and maximum number of instances
  • When EC2 instances should scale in or out

Once these settings are in place, AWS automatically adjusts the number of EC2 instances for you.

Configure Auto Scaling
↓
Traffic increases
↓
Add EC2 instances

Traffic decreases
↓
Remove EC2 instances

An EC2 instance fails
↓
Launch a new EC2 instance
Enter fullscreen mode Exit fullscreen mode

In other words, Auto Scaling is a way to define how many EC2 instances you need and when they should scale, then let AWS manage them automatically.

In this article, we'll take a simple look at the main settings used with EC2 Auto Scaling.

What Is an Auto Scaling Group?

At the center of EC2 Auto Scaling is the Auto Scaling Group (ASG).

An Auto Scaling Group manages how many EC2 instances should be running.

There are three main capacity settings:

Setting Meaning
Minimum Minimum number of instances to maintain
Desired Number of instances you want running
Maximum Maximum number of instances allowed

For example:

Minimum = 2
Desired = 2
Maximum = 6
Enter fullscreen mode Exit fullscreen mode

With these settings:

Normally
EC2 × 2

Traffic increases
↓
Scale up to EC2 × 6

Traffic decreases
↓
Return to EC2 × 2
Enter fullscreen mode Exit fullscreen mode

What Is a Launch Template?

The Auto Scaling Group also needs to know what kind of EC2 instance it should launch.

This is where a Launch Template is used.

A Launch Template can define settings such as:

  • AMI
  • Instance type
  • Security Group
  • IAM
  • User Data
  • Storage

A simple way to think about it is:

Launch Template
↓
What kind of EC2 instance?

Auto Scaling Group
↓
How many instances?
Enter fullscreen mode Exit fullscreen mode

What Is a Scaling Policy?

Next, you need to define when EC2 instances should be added or removed.

This is done with a Scaling Policy.

For example:

CPU usage increases
↓
Add EC2 instances

CPU usage decreases
↓
Remove EC2 instances
Enter fullscreen mode Exit fullscreen mode

Adding instances is called Scale Out, while removing instances is called Scale In.

One common option is Target Tracking Scaling.

For example, you can set a target such as:

Keep average CPU utilization around 50%
Enter fullscreen mode Exit fullscreen mode

AWS then adjusts the number of EC2 instances to help maintain that target.

Using Auto Scaling with an ALB

For web applications, Auto Scaling Groups are commonly used with an Application Load Balancer (ALB).

             Internet
                 ↓
                ALB
                 ↓
       ┌─────────┼─────────┐
       ↓         ↓         ↓
     EC2 #1    EC2 #2    EC2 #3
Enter fullscreen mode Exit fullscreen mode

When Auto Scaling adds a new EC2 instance, the ALB can distribute traffic to that instance as well.

Traffic increases
↓
Add EC2 instance
↓
ALB distributes traffic to the new instance
Enter fullscreen mode Exit fullscreen mode

What Happens If an EC2 Instance Fails?

Auto Scaling isn't only about adding and removing instances based on traffic.

It also helps maintain the required number of EC2 instances.

For example:

Desired = 2

EC2 #1 → Healthy
EC2 #2 → Unhealthy
Enter fullscreen mode Exit fullscreen mode

If an instance becomes unhealthy, the Auto Scaling Group can launch a replacement to maintain the desired capacity.

EC2 instance fails
↓
Launch a new EC2 instance
↓
Maintain 2 instances
Enter fullscreen mode Exit fullscreen mode

This is another reason Auto Scaling is useful for improving availability.

Where Do You Configure Auto Scaling in AWS?

In the AWS Management Console, go to:

EC2
↓
Auto Scaling
↓
Auto Scaling Groups
Enter fullscreen mode Exit fullscreen mode

When creating an Auto Scaling Group, you can think of the configuration like this:

Launch Template
↓
What kind of EC2 instance?

Minimum / Desired / Maximum
↓
How many instances?

Scaling Policy
↓
When should they scale?
Enter fullscreen mode Exit fullscreen mode

Check the Activity History

After creating an Auto Scaling Group, you can check its Activity history to see what happened.

For example:

Why was an EC2 instance added?

Why was an EC2 instance removed?

Why was a new EC2 instance launched?
Enter fullscreen mode Exit fullscreen mode

This is useful when investigating Auto Scaling behavior.

Is Auto Scaling Difficult?

The basic concept of Auto Scaling is fairly simple.

What kind of EC2 instance?
→ Launch Template

How many instances?
→ Auto Scaling Group

When should they scale?
→ Scaling Policy
Enter fullscreen mode Exit fullscreen mode

Once these settings are configured, AWS handles the actual scaling automatically.

In real-world environments, however, you still need to consider:

  • Which metrics should trigger scaling
  • What the minimum and maximum capacity should be
  • How ALB and health checks should be configured
  • Whether your application can handle instances being added and removed

So the configuration itself isn't necessarily difficult. The more important part is deciding which settings are appropriate for your system.

Summary

Amazon EC2 Auto Scaling automatically manages the number of EC2 instances you need.

The basic configuration is:

Launch Template
↓
What kind of EC2 instance?

Auto Scaling Group
↓
How many instances?

Scaling Policy
↓
When should they scale?
Enter fullscreen mode Exit fullscreen mode

After that, AWS can automatically handle situations such as:

Traffic increases
→ Add EC2 instances

Traffic decreases
→ Remove EC2 instances

An EC2 instance fails
→ Launch a replacement
Enter fullscreen mode Exit fullscreen mode

So rather than thinking of Auto Scaling as something you need to implement yourself, it's easier to think of it as defining the rules in AWS and letting AWS manage your EC2 instances automatically.

Top comments (0)