How To Configure AWS EC2 Auto Scaling
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
How Do Auto Scaling Groups Work?
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
Scaling Cooldowns
Instance Refresh
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.
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.
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.
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.
Leave tags optional and click next.
On this page, review and click create auto-scaling-group.
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!