How does it work practically?

Image source: Image curled from AWS Documentation
A specified number of instances are created and packaged in a group called the auto-scaling group, which is treated as a logical unit for scaling and management purposes.
Amazon EC2: Auto Scaling
Auto Scaling guarantees that there are enough Amazon EC2 instances to run your application. We can set up an auto-scaling group with a selection of EC2 instances. We can specify the minimum quantity of AWS EC2 instances in that group, and auto-scaling will maintain and ensure that number. We can also specify the maximum number of AWS EC2 instances in each auto-scaling group, and auto-scaling will make sure that instances do not surpass that limit. For Amazon EC2 auto-scaling, we can also specify desired capacity and auto-scaling policies. Auto-scaling can initiate or discontinue AWS EC2 instances based on demand by using the scaling policy.
Auto Scaling Life Cycle
The EC2 Instance in the Auto Scaling Group follows a path or has a life cycle (that differs from other ec2 instances).

Image source: life cycle of auto-scaling
The life cycle begins when the Auto Scaling group tries to launch and puts an instance into service.
The life cycle ends once the instance is halted by the Auto Scaling group, or when the instance is taken out of service as well as terminated by the Auto Scaling group.
Let us discuss all the life cycle states in detail:
-
Scale-Out: It Specifies that the Auto Scaling group should launch an EC2 instance and attach it to the group.
-
Instance in service: The instance will remain in the service state until one of the following states occurs.
→ The Scale In event occurs, and Amazon Auto Scaling decides to terminate the instance to reduce the size of the Auto Scaling group.
→ place the instance in the Stand-By state
→ Disconnect the instance from the auto-scaling group.
→ If an instance fails a certain number of health checks, it is eliminated from the auto-scaling group.
-
Scale-In: It instructs the Auto Scaling group to disassociate and terminate EC2 instances from the group.
-
Attach an Instance —We can add a running EC2 instance that meets certain requirements to our Auto Scaling group. After attaching the instance, it is managed as a member of the Auto Scaling group.
-
Detach an Instance — We can disconnect an instance from your Auto Scaling group. After you detach the instance from the Auto Scaling group, you can manage it independently or connect it to a different Auto Scaling group.
-
Life cycle Hooks — We can add a life cycle hook to our auto-scaling group to perform custom actions when instances start or stop.
→ Scale-Out: (it launches one or more instances) -instances begin in the PENDING STATE if we added the "autoscaling: EC2 INSTANCE LAUNCHING" hook to our auto-scaling group, instances move from the PENDING WAIT STATE, and instances enter the PENDING: PROCEED state after the life cycle action is completed. When the instances are finished configuring, they are added to the Auto Scaling group and enter the Inservice state. PENDING -> {PENDING WAIT & PENDING PROCEED STATE} lifecycle action added -> INSERVICE STATE.
→ Scale-In: (it detaches one or more instances) -instances are separated in the TERMINATING STATE, and if we added the "autoscaling: EC2 INSTANCE TERMINATING" hook to our auto-scaling group, the instances move from the TERMINATING WAIT STATE, and after the life cycle action is completed, the instances enter the TERMINATING: PROCEED state. They are fully terminated when the instances are fully terminated.
TERMINATING -> {TERMINATING WAIT & TERMINATING PROCEED STATE }life cycle action added -> TERMINATED.
- Enter and Exit Stand By: Change any instance in the INSERVICE state to the STANDBY state. This allows you to deactivate the instance, troubleshoot or bring alterations to it, and then reactivate it. The Auto Scaling group continues to manage instances in the STANDBY state. But even so, they are not an active part of your assessment until they are re-enabled.
Components of Auto-scaling
-
Groups: They are logical groups that contain a collection of EC2 instances with similar features for scaling and management. We can specify the minimum, maximum, and a preferred number of EC2 instances when you create a group.
-
Launch Configuration: It is a template for launching EC2 instances used by the auto-scaling group. While creating the launch configuration, we can specify information for your instances such as the AMI ID, instance type, key pair, and system services.
- Scaling Plan: The scaling strategy instructs Auto Scaling on when and how to scale. Amazon EC2 auto-scaling automatically scales the auto-scaling group in the following ways:
Benefits of Auto-scaling
-
Auto Scaling dynamically adapts the capacity of the resources to maintain high service quality. It also helps when the workload is random, unexpected, and changes on a regular basis.
-
AWS Autoscaling generates all scaling policies and targets for the individual based on their preferences. It also improves our understanding of how different resource groups respond to changes in demand.
- Auto-scaling will assist in managing all resource provisioning for the application's EC2 auto-scaling groups and tables.
Auto-scaling service quotas
Default Limits:
Launch configurations per Region: 200
Auto Scaling groups per Region: 200
Auto Scaling Group Limits:
Scaling policies per Auto Scaling group: 50
Scheduled actions per Auto Scaling group: 125
Lifecycle hooks per Auto Scaling group: 50
SNS topics per Auto Scaling group: 10
Classic Load Balancers per Auto Scaling group: 50
Target groups per Auto Scaling group: 50
Scaling Policy Limits:
Step adjustments per scaling policy: 20
Frequently Asked Questions
What Are Some of the Security Best Practices for Amazon EC2?
Using Identity and Access Management (IAM) to limit access to AWS resources; limiting access by only allowing reliable hosts or networks to access ports on an instance; only allowing those permissions you require, and deactivating password-based logins for instances started from your AMI are all security best practices for Amazon EC2.
What is the difference between stopping and terminating an EC2 instance?
When you stop an EC2 instance, it goes into a stopped state and performs a normal shutdown. When you terminate an instance, it is put into a stopped state, and any EBS volumes connected to it are immediately removed and cannot be recovered.
What are the different types of EC2 instances based on their costs?
The following are the three types of EC2 instances:
- Instances available on demand: It is cost-effective for a limited time, but not in the long run.
- Instance on the Spot: It is less pricey than on-demand and can be purchased through a bidding process.
- The instance that has been reserved: This is the proper instance for you if you plan on using it for a year or longer.
Conclusion
To summarise, this blog first discussed the term auto-scaling. We also looked at why auto-scaling is necessary. After that, we discussed Amazon EC2: Auto Scaling, its life cycle, components, and benefits. Finally, we talked about auto-scaling service quotas.
We believe that this blog has assisted you to learn more about AWS EC2 Auto Scaling. This isn't the end; if you're curious to learn more, check out our other AWS articles here. Do upvote our blog to help other ninjas grow.
Happy Coding!