What is Auto Scaling group in AWS?

An Amazon Web Services (AWS) Auto Scaling Group (ASG) is a service that helps you automatically adjust the number of Amazon Elastic Compute Cloud (EC2) instances in a group based on demand or a defined schedule. The goal of an Auto Scaling Group is to ensure that your application or service maintains the desired level of availability, performance, and cost efficiency by automatically adding or removing instances as needed.

Benefits of AWS Auto Scaling Groups

Improved Availability and Fault Tolerance: Auto Scaling Groups distribute instances across multiple Availability Zones (AZs) to enhance fault tolerance. If an AZ becomes unavailable, the instances in that zone are replaced, helping ensure your application’s high availability.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Dynamic Scaling Based on Demand: ASGs automatically scale the number of instances up or down in response to changes in demand. This ensures your application can handle sudden spikes in traffic and reduces the risk of performance degradation during peak usage periods.

Cost Efficiency: Auto Scaling Groups help optimize costs by automatically increasing the number of instances when demand is high and decreasing them during periods of lower demand. This avoids over provisioning, where you have more resources than necessary, and helps reduce costs during idle periods.

Application Performance and Scaling Policies: ASGs allow you to define scaling policies based on specific metrics, such as CPU utilization, network traffic, or custom application metrics. This enables you to fine-tune the scaling behaviour to meet your application’s performance requirements.

Download Banner

Easy Management and Maintenance: Managing instances manually can be time-consuming and error-prone. ASGs handle instance provisioning, termination, and replacement automatically, reducing the administrative burden and minimizing downtime during updates or maintenance.

Flexible Configuration: ASGs support various scaling strategies, including:

  • Manual Scaling: You can manually adjust the number of instances in the group
  • Scheduled Scaling: You can schedule scaling actions based on known usage patterns
  • Dynamic Scaling: Instances are added or removed based on defined policies and real-time metrics

Elastic Load Balancing Integration: ASGs can work seamlessly with Elastic Load Balancing (ELB) to distribute incoming traffic across instances in the group, further enhancing application availability, fault tolerance, and scalability.

Conditions on which auto scaling groups can be configured

Amazon Web Services (AWS) Auto Scaling Groups (ASGs) allow you to configure scaling based on specific conditions or triggers to automatically adjust the number of instances in a group. The conditions on which you can configure auto scaling in AWS include:

  • Scheduled Scaling: You can configure your Auto Scaling Group to automatically adjust the desired capacity of instances at specific times or on specific dates. This is useful when you know in advance when your application’s demand will increase or decrease
  • Dynamic Scaling: Dynamic scaling adjusts the number of instances based on real-time metrics. This includes conditions such as:
  • Target Tracking Scaling: You can set a target value for a specific metric, such as CPU utilization or request count per instance. Auto Scaling adjusts the number of instances to maintain the metric at or near the target value
  • Simple Scaling: You define scaling policies based on thresholds for a specific metric. When the metric crosses the threshold, Auto Scaling adds or removes instances as needed
  • Step Scaling: Similar to simple scaling, but you define different scaling adjustments for different ranges of the metric. This allows more granular control over scaling behavior
  • Custom Application Metrics: You can configure Auto Scaling based on custom application metrics that you send to Amazon CloudWatch. This allows you to create scaling policies based on your application’s specific performance metrics
  • Load Balancer Metrics: Auto Scaling can use metrics from Elastic Load Balancing (ELB), such as request count or latency, to trigger scaling actions. This ensures that the number of instances is adjusted based on load balancer performance
  • Manual Scaling: While not automatic, you can manually adjust the size of your Auto Scaling Group as needed. This can be useful for short-term adjustments or during maintenance periods

It’s important to choose the appropriate scaling approach based on your application’s characteristics, traffic patterns, and performance requirements. Combining multiple scaling conditions can provide more fine-grained control over how your Auto Scaling Group responds to changes in demand. Always monitor and fine-tune your scaling settings to ensure optimal performance and cost efficiency.

Step-by-Step Guide on How to Create Auto Scaling groups using Amazon EC2 Launch Template

Configuring Auto Scaling Groups (ASGs) on Amazon Web Services (AWS) allows you to automatically adjust the number of instances in a group based on demand or a defined schedule. This helps ensure optimal performance, availability, and cost efficiency for your applications.

Here’s a guide on how to create EC2 Auto Scaling Groups in AWS:

On the EC2 dashboard of your AWS console, select the ‘Auto Scaling Group’ in the left hand side menu and then click on “Create Auto Scaling group”

Auto Scaling Groups Using EC2 Launch Templates

Step 1: Enter a name and select the launch template for the auto scaling group. A launch template contains instance settings such as EC2 AMI, instance type, key pair and security groups.

For this demo, we give the name for the auto scaling group as “demo-asg-01”

Auto Scaling Groups Using EC2 Launch Templates

Since there is no launch template available, we will create a new launch template. Click on “Create a launch template” option.

Auto Scaling Groups Using EC2 Launch Templates

In the next screen, you can enter the following details to create a new template.

Provide a name for the launch template and a version for the template. You can now enable the checkbox, “Provide guidance to help me set up a template that I can use with EC2 Auto Scaling”.

Auto Scaling Groups Using EC2 Launch Templates

Now, select the AMI to be used for this template. Here, we are choosing Amazon Linux AMI.

Auto Scaling Groups Using EC2 Launch Templates

Select the instance type that is required to be launched as part of the template. Here we are selecting the option as t2.micro as the instance type to be deployed through the launch template.

Auto Scaling Groups Using EC2 Launch Templates

Now, select the key pair to be used for logging in to your EC2 instance.

Auto Scaling Groups Using EC2 Launch Templates

In the network settings, do not select any subnet. Select the security groups to be used or the template.

Auto Scaling Groups Using EC2 Launch Templates

Select the storage to be configured by the launch template.

Auto Scaling Groups Using EC2 Launch Templates

Now click on “Create launch template”.

Auto Scaling Groups Using EC2 Launch Templates

Now, let’s go back to the webpage to create the auto scaling groups. In the launch template option, select the launch template that you have created in the previous steps. It will display the deployment options configured in the template.

Auto Scaling Groups Using EC2 Launch Templates

Step 2: Choose instance launch options

Here you can select the network VPC and the subnets. You can choose multiple subnets in multiple availability zones.

Auto Scaling Groups Using EC2 Launch Templates

The instance type requirements are automatically displayed once you choose the network and subnet details in the previous step.

Auto Scaling Groups Using EC2 Launch Templates

Step 3: Configure advanced options

In this step, we will leave all the options as default such as Load Balancing, VPC Lattice Integration Options, Health Checks and Additional Settings such as Monitoring & Instance Warm-up.

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

Step 4: Configure the group size and scaling policies

Here for the group size, the desired capacity is 1 instance, the minimum capacity is 1 instance, and maximum capacity is 2 instances.

Auto Scaling Groups Using EC2 Launch Templates

In the scaling policies, select the conditions based on which the EC2 instances have to scale out. Here, we are choosing the target tracking scaling policy and the metric type as “Average CPU utilization” and target value is 20. When the EC2 instance CPU utilization crosses 20 % usage, the instance is scaled out automatically.

The instance warm-up time is 60 seconds, which means, after the EC2 instance is scaled out, the newly created instance is not counted towards the EC2 metrics until the warm-up time of 60 seconds expires.

Auto Scaling Groups Using EC2 Launch Templates

Configuring instance scale-in protection prevents the auto scaling group from scaling in when the metric goes below the target value. Here, we are not enabling instance scale-in protection.

Auto Scaling Groups Using EC2 Launch Templates

Step 5: Add Notifications & Tags (Optional)

Notifications can be enabled for SNS topics. Tags can be added for search and filter. For this demo, we are not enabling notifications & tags.

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

Step 6: Review and create the auto scaling group

In this step, all the details configured in the previous steps will be shown. If you need to change any setting, you can edit and change it now. Else, you can create the auto scaling group.

what is aws auto scaling group

Auto Scaling Groups Using EC2 Launch Templates

what is aws auto scaling group

what is aws auto scaling group

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

When you click on “Create auto scaling group”, the auto scaling group is created, and it is in a state “Updating capacity” (i.e) it creates the EC2 instance as per the desired capacity that we have configured.

Auto Scaling Groups Using EC2 Launch Templates

After the instance is created and the desired capacity is reached, the status of the auto scaling group looks like the below (refer screenshot). The instance count is changed to 1, which is the desired capacity of this group.

what is auto scaling group aws

Now, you can open the auto scaling group and select instance management. There you can find the EC2 instance created by the auto scaling group.

Test the auto scaling group

Login to the EC2 instance created by the auto scaling group and initiate load stress on the EC2 instance so that the CPU utilization goes above 20%.

Here, we use a simple Linux ‘dd’ command to simulate load on the server.

Once the command is executed, it increases the load on the server.

Auto Scaling Groups Using EC2 Launch Templates

Here, we can see the CPU is 100% utilized.

c2 auto scaling group

After some time, we can see in the auto scaling group “Activity History” that a new instance is created to increase the capacity to 2 as per the configuration.

Auto Scaling Groups Using EC2 Launch Templates

Under the instance management section in the auto scaling group, we can see two instances created by the auto scaling group.

what is auto scaling group in aws

Now, we have stopped the load stress on the EC2 instance, and the CPU usage is idle now.

Auto Scaling Groups Using EC2 Launch Templates

Auto Scaling Groups Using EC2 Launch Templates

After some time, the activity history shows that one out of the 2 instances in this group is terminated as the CPU usage is gone below 20%.

aws auto scaling group

aws auto scaling group

Conclusion

By leveraging AWS EC2 Launch Templates to create auto scaling groups, you can automate resource adjustments, ensuring your infrastructure is always aligned with demand. Implementing auto scaling not only improves efficiency but also provides cost savings, making it an essential practice for managing cloud environments.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post