Accend Networks San Francisco Bay Area Full Service IT Consulting Company

How To Configure AWS EC2 Auto Scaling

aws ec2 auto scaling groups

Amazon Web Services (AWS) offers a robust solution through Auto Scaling Groups, facilitating automatic adjustments to instance numbers based on demand.

Auto Scaling Group Fundamentals

In real-world scenarios, the demand for websites and applications can fluctuate significantly. AWS Auto Scaling Groups allow rapid creation or termination of servers to accommodate these changes. The key objectives of ASGs encompass dynamically adding or removing EC2 instances based on demand, setting limits on instance numbers, and ensuring the automatic registration of newly launched instances with load balancers. Furthermore, ASGs are designed to replace terminated instances, ensuring continuous availability, all while being cost-effective as you only pay for the underlying EC2 instances.

How Do Auto Scaling Groups Work?

The size of your auto scaling group is maintained according to a pre-defined number of instances, which you configure as the required capacity. You can use manual or automatic sizing to resize groups according to application requirements.

Initially, an auto scaling group launches enough instances to reach the required capacity. By default, it maintains this number of instances by performing regular health checks, identifying unhealthy instances, terminating them and launching other replacement instances.

So let’s look at auto-scaling policies

Auto Scaling and CloudWatch Alarms

Target Tracking Scaling

First, consider a scenario where you want to maintain an average CPU utilization of 40%.

Simple/Step Scaling

Then, for a more granular approach, consider Simple/Step Scaling.

Scheduled Actions

Next, Scheduled Actions can be employed in scenarios where scaling needs can be anticipated. e.g. an increase in minimum capacity to 10 at 5 pm every Friday.

Predictive Scaling

Now, Predictive Scaling introduces a proactive approach by continuously analyzing historical data.

Metrics for Scaling

Choosing appropriate metrics is crucial. Consider metrics such as average CPU utilization, requests per EC2 instance, average network in/out, or custom metrics pushed using CloudWatch.

Scaling Cooldowns

To prevent rapid and unnecessary scaling activities, cooldown periods are essential.

Instance Refresh

Instance Refresh allows you to update the launch template of your Auto Scaling Group and then gradually replace instances with the new configuration. This process helps you seamlessly apply changes to your instances, ensuring that your application remains available and responsive during the update.

Auto Scaling Group Configuration

To create an autoscaling group, firstly start by creating a launch template. Then launch template specifies how to configure EC2 instances that are going to be launched by an autoscaling group. We will do this practically.


Go to the log into the management console, type EC2 in the search box, and select EC2 under services.


In the EC2 console on the left side of the navigation pane under instances, click launch templates, then click Create launch template.

aws ec2 auto scaling groups

Give your template a name, I will call it Auto-scaling-Template and then you can skip the version description for now and scroll down.

We will do configurations for our launch template. Under launch template contents under Application and OS images, select the QuickStart tab then select Amazon Linux. Then under Amazon Machine Image (AMI) select the dropdown and select Amazon Linux 2 AMI. Scroll down.

Under instance type select the drop-down button and select t2. Micro because it is the free one. Then under key-pair login, select the drop-down and select your key-pair. Scroll down.

In the network settings section, for subnet Leave it as it is. Then move to firewall and security, then select the existing security group. For security groups, select your security groups. I created a security group and opened port 22 for SSH and called it SSH security group. Again, I opened ports 80 and 443 for HTTP and HTTPS traffic and called this security group, web traffic. Scroll down. Leave all the other settings as default and click Create Launch template.
Come back to the EC2 dashboard at the bottom left of the navigation pane and select Auto Scaling groups.
aws ec2 auto scaling groups
aws ec2 auto scaling groups
In the create auto-scaling group dashboard under the name, give a name to your auto-scaling group. Then in the launch template section, select the drop-down and choose the template you just created. Then scroll down and click next.

Under network, select your VPC, I will move with the default VPC and then under availability zone, select the drop-down and select your AZs, I will select Us-east-1a, and then 1b AZs then scroll down and click next.

aws ec2 auto scaling groups
Under the configure advance option because we don’t have a load balancer, we will pass that page and click next. Then under the configure group size and scaling section, under desired capacity, select 2, then scroll down.
For scaling limits, minimum desired capacity select 1, and for maximum desired capacity select 4. Leave the other options and click next.
We will not add notification, click next.

Leave tags optional and click next.

On this page, review and click create auto-scaling-group.

When you come back to the EC2 dashboard under instances already we can confirm autoscaling has provisioned our desired capacity instances.
This brings us to the end of this demo. Pull down everything. Stay tuned for more.

If you have any questions concerning this article or have an AWS project that requires our assistance, please reach out to us by leaving a comment below or email us at [email protected].

Thank you!

Written By :

Victor Onyango, AWS Certified Solutions Architect – Associate

Leave a Reply