Amazon EC2 Auto Scaling helps us ensure, that we have the proper number of Amazon EC2 instances available, to handle the load for our application.
We create collections of EC2 instances, called Auto Scaling groups.
I can specify the minimum number of instances in each Auto Scaling group, and Auto Scaling ensures that your group never goes below this size.
I can specify the maximum number of instances in each Auto Scaling group, and Auto Scaling ensures that your group never goes above this size.
If we specify the desired capacity, either when you create the group or at any time thereafter, Auto Scaling ensures that your group has this many instances..
The scaling policies that we define adjust the number of instances, within your minimum and maximum number of instances, based on the criteria that we specify.
Fleet managment: You can use Amazon EC2 Auto Scaling for Fleet management of EC2 instances : to help maintain the health and availability of our fleet.
Dynamic Scaling: You can also use Amazon EC2 Auto Scaling for dynamic scaling of EC2 instances in order to automatically increase the number of Amazon EC2 instances during demand spikes to maintain performance and decrease capacity during lulls to reduce costs.
Auto Scaling EC2, has two aspects to it overall:
I) Fleet Management
----------------------------
Whether you are running one Amazon EC2 instance or thousands you can use Amazon EC2 Auto Scaling to detect impaired Amazon EC2 instances and unhealthy applications, and replace the instances without your intervention.
This ensures that your application is getting the compute capacity that you expect.
Amazon EC2 Auto Scaling will perform three main functions to automate fleet management for EC2 instances:
- Monitor the health of running instances : Amazon EC2 Auto Scaling ensures that our application is able to receive traffic and that EC2 instances are working properly.
Amazon EC2 Auto Scaling periodically performs health checks : to identify any instances that are unhealthy.
- Replace impaired instances automatically:
When an impaired instance fails a health check,
Amazon EC2 Auto Scaling automatically terminates it and replaces it with a new one.
That means that you don’t need to respond manually when an instance needs replacing.
- Balance capacity across Availability Zones Amazon EC2 Auto Scaling can automatically balance instances across zones, and always launches new instances so that they are balanced between zones as evenly as possible across your entire fleet.
II) Dynamic Scaling
---------------------------
- Amazon EC2 Auto Scaling enables you to follow the demand curve for your applications closely,
reducing the need to manually provision Amazon EC2 capacity in advance.
For example, we can use target tracking scaling policies to select a load metric for your application, such as CPU utilization.
Or, you could set a target value using the new “Request Count Per Target” metric from Application Load Balancer, a load balancing option for the Elastic Load Balancing service. Amazon EC2 Auto Scaling will then automatically adjust the number of EC2 instances as needed to maintain our target.
We can also use simple scaling policies to set a condition to add new Amazon EC2 instances in increments when the average utilization of your Amazon EC2 fleet is high, and similarly, you can set a condition to remove instances in the same increments when CPU utilization is low.
If you have predictable load changes, you can also set a schedule through Amazon EC2 Auto Scaling
to plan your scaling activities.
In addtion:
1) Amazon EC2 Auto Scaling can also be used with Amazon CloudWatch, which can send alarms to trigger scaling activities, and Elastic Load Balancing to help distribute traffic to your instances within EC2 Auto Scaling groups.
2) We can also use Amazon EC2 Auto Scaling
in combination with AWS Auto Scaling to scale multiple services.
Finally, before viewing the steps need to implement, the Summary of this article is:
Amazon EC2 Auto Scaling helps you maintain application availability and allows you to dynamically scale up or down your Amazon EC2 capacity automatically according to conditions you define.
Steps to Implement
Setting Up
Before you start using Amazon EC2 Auto Scaling, we have to complete the following tasks.
Prepare to Use Amazon EC2
If you haven't used Amazon EC2 before, complete the tasks described in the Amazon EC2 documentation.
Getting Started
When you use Amazon EC2 Auto Scaling, we must use certain building blocks to get started.
Setting up the basic infrastructure for Amazon EC2 Auto Scaling:
Tasks
Step 1: Create a Launch Template
Step 2: Create an Auto Scaling Group
Step 3: Verify Your Auto Scaling Group
Step 4: (Optional) Delete Your Scaling Infrastructure
Launch Configurations
Creating a Launch Configuration
Creating a Launch Configuration Using an EC2 Instance
Changing a Launch Configuration
Launching Auto Scaling Instances in a VPC
Auto Scaling Groups
Creating a Group Using a Launch Template
Creating a Group Using a Launch Configuration
Creating a Group Using an EC2 Instance
Creating a Group Using the Launch Wizard
Tagging Auto Scaling Groups and Instances
Using a Load Balancer With an Auto Scaling Group
Launching Spot Instances in Your Auto Scaling Group
Merging Auto Scaling Groups
Deleting Your Auto Scaling Infrastructure
Scaling Your Group
Maintaining the Size of Your Auto Scaling Group
Manual Scaling
Scheduled Scaling
Dynamic Scaling
Scaling Cooldowns
Auto Scaling Instance Termination
Lifecycle Hooks
Temporarily Removing Instances
Suspending and Resuming Processes
Monitoring Your Auto Scaling Instances and Groups
Health Checks
Amazon CloudWatch Metrics
Amazon CloudWatch Events
Amazon SNS Notifications
AWS CloudTrail Logging
Controlling Access to Your Resources
Service-Linked Roles
Launch Auto Scaling Instances with an IAM Role