Day 3 -
Today we are discussing a complete end to end AWS ASG (Auto Scaling and Auto Scaling group) in our 100DayOfRandomLearning series.
What is auto-scaling in AWS?
Auto-scaling is a service offered by Amazon Web Services in which scale-in and scale-out of instances will be handled automatically as per the launch configuration/template specified.
Auto-scaling is one of the best services offered by AWS.
Best Practice:
In order to work with auto-scaling smoothly, there is a need to deploy a load balancer as well.
Let's dive into the hands-on without wasting any more second -
we will go through the theory (definition, concepts, and many more) simultaneously.
Prerequisites -
No instance is running.
Application Load Balancer is running with no registered targets.
On Day 2, we learn how to create a Load Balancer in AWS with complete hands-on and labs.
Click here for Day2 [Elastic Load Balancer].
Configure the Security Group for EC2 and ALB ( Application Load Balancer )
Click here for Complete Security Group Setup.


Once the template created successfully, go to view templates and verify all the configuration is correct.
Change the health check grace period if required otherwise leave as it is.
Additional Settings - Enable Monitoring ( in order to collect cloudwatch logs for triggering alarms )
Choose Scaling Policies - Target tracking Scaling Policy or None ( if choose none, you can select scaling policy after the creation of the Auto Scaling group.
Setup an Auto-Scaling
Once all the prerequisites are fulfilled we are good to set up auto-scaling and launch configuration.
Go to EC2 Dashboard > Auto Scaling > Launch Configuration > Create Launch Configuration
In launch configuration, click on "Start Using Launch Templates" present in the top information bar.
******Random Bytes******
Difference between Launch Configuration and Launch Templates
Launch Configuration -
- A launch configuration is an instance configuration template that an Auto Scaling group uses to launch EC2 instances.
- One launch configuration for an Auto Scaling group at a time.
- You can't modify a launch configuration after you've created it.
Launch Template -
- A launch template is similar to a launch configuration, in that it specifies instance configuration information.
- Launch template allows you to have multiple versions of a template.
- Versioning helps in reusing it to create other templates or template versions.
- Launch template creates an auto-scaling group that launches both Spot and On-Demand Instances or that specifies multiple instance types.
********************
Configure launch template -
Enter the below details:
Enter the template name
Enter the template name
Specify the AMI (t2.micro if you are free tier eligible)
Enter the AMI
Enter the Instance type
Specify the Key-pair
Under Networking section - ( Choose VPC, Subnet and Security Group )
Select the storage volume
Under Advanced details - go to User Data > type the script mentioned in the image.
Hurrah !!!! We have created our first launch template successfully.
Once the template created successfully, go to view templates and verify all the configuration is correct.
Go to EC2 Dashboard > Go to Auto Scaling > Click on Auto Scaling Group.
Click on Create Auto Scaling Group
Enter the Auto Scaling Group and Select the latest created launch configuration. > Click on Next
Choose Purchase option and in Network, option Select VPC, and subnet ( for high availability select more than one subnets).
Enable load balancing - for high availability if selected application load balancer then needs to choose the target group as well.
Select the health checks - for additional health checks to enable ELB.
Change the health check grace period if required otherwise leave as it is.
Additional Settings - Enable Monitoring ( in order to collect cloudwatch logs for triggering alarms )
******Random Bytes******
Difference between EC2 and ELB health checks?
EC2 Health Checks -
It is configured by default in EC2 instances.
It checked the status of hardware and network configuration, if anything found misconfigured it marked the instance as faulty.
Works on the instance level.
ELB Health Checks -
Using to check the availability of instances by pinging and verified whether the instance is accepting connection or not.
It checked whether the instance returns a 200 status code or not.
Works on the App-level instead of checking the instance it smartly verifies whether the application is working or not.
What is the Health Check Grace Period?
The amount of time until EC2 Autoscaling performs the first health check on new instances after they are put in-service.
*************************
Choose Group size - Desired, Min and Max
Choose Scaling Policies - Target tracking Scaling Policy or None ( if choose none, you can select scaling policy after the creation of the Auto Scaling group.
Optional - Instance Scale-in Protection ( Protect instance from automatic scale-in)
Review the auto-scaling group configuration if all good then click on Create Autoscaling group
Hurrah !!! Our First Auto Scaling Group created successfully.
******Random Bytes******
Difference Between Desired, Min, and Max Capacity in the auto-scaling group?
AWS Study Combo Pack -
Desired Capacity-
No. of instances launched first as per the number specified in the desired capacity.
The desired capacity can be varied as per the Scaling policies defined.
Desired capacity must be between min and max.
Min Capacity-
No. of an instance will never decrease as per the number specified in min capacity.
Max Capacity-
No. of an instance will never be increasing as per the number specified in max capacity.
Difference between Auto-Scaling policies?
Simple Scaling -
The simple scaling policy is a simple straightforward policy in which you need to add cloud watch metrics such as CPU utilization if your specified metric reaches the threshold then either two actions will performed add or remove the number of instances.
Step Scaling -
It provides more flexibility in which we can define multiple responses/conditions, if either of the responses set to true then adds or removes actions will be triggered.
Benefits - can help in defining multiple responses.
Target Tracking Scaling -
It is one of the famous scaling policies in which all we need to specify the condition rest will be taken care of by the policy.
No need to mention add or remove action it will automatically add or remove an instance if it reaches the threshold/conditions.
It is self-scaling ( add or remove automatically )
It's an algorithm written in such a manner - that this policy learns from the cloud watch metric and takes the appropriate actions.
*************************
Validation
Open the Auto Scaling group > Go to activity > Check whether any instance status is present either preservice or successful.
In order to change scaling policy > Go to automatic scaling > Select the existing one - delete it and add a new scaling policy ( either step, simple and target tracking )
EC2 Dashboard > Go to Load Balancer > Open the target group > Click on target > Verify whether the instance is registered in load balancer or not.
EC2 Dashboard > Go to Load Balancer > from description > copy the DNS
Start playing with an auto-scaling group size value -
1. Change the Desired capacity value
2. Check the changes in auto-scaling group > Activity tab
Click here AWS Certification Preparation Guide
Click here AWS Certification CheatSheet
Click here AWS Study Material
0 Response to "Day 3 - AWS Auto Scaling Zero to Hero | AWS ASG | Hands-on | Certification Tips"
Post a Comment
Hey Random,
Please let me know if you have any query :)