Please note: This workshop version is now deprecated, and an updated version has been moved to AWS Workshop Studio. This workshop remains here for reference to those who have used this workshop before for reference only. Link to updated workshop is here: Efficient and Resilient Workloads with Amazon EC2 Auto Scaling.
Amazon EC2 Auto Scaling helps you maintain application availability and allows you to dynamically scale your Amazon EC2 capacity up or down automatically according to conditions you define. You can use Amazon EC2 Auto Scaling for fleet management of EC2 instances to help maintain the health and availability of your fleet and ensure that you are running your desired number of Amazon EC2 instances. about Amazon EC2 Auto Scaling and the several ways to configure scaling policies for your application.
You have decided to leverage EC2 Auto Scaling to scale your application efficiently. To start, you create an EC2 Auto Scaling group without any Auto Scaling policies.
ec2-spot-workshops/workshops/efficient-and-resilient-ec2-auto-scaling
.cat ./asg.json
aws autoscaling create-auto-scaling-group --cli-input-json file://asg.json
aws autoscaling enable-metrics-collection \
--auto-scaling-group-name ec2-workshop-asg \
--granularity "1Minute"
Do you know different ways to scale the capacity of your Auto Scaling group?
Go to Scale the size of your Auto Scaling group documentation page for more information.
You can scale the capacity of your Auto Scaling group using below scaling policies.
At any time, you can change the size of an existing Auto Scaling group manually. You can either update the desired capacity of the Auto Scaling group, or update the instances that are attached to the Auto Scaling group. Manually scaling your group can be useful when automatic scaling is not needed or when you need to hold capacity at a fixed number of instances.
A dynamic scaling policy instructs Amazon EC2 Auto Scaling to track a specific CloudWatch metric, and it defines what action to take when the associated CloudWatch alarm is in ALARM. The metrics that are used to invoke the alarm state are an aggregation of metrics coming from all of the instances in the Auto Scaling group. When the policy is in effect, Amazon EC2 Auto Scaling adjusts the group’s desired capacity up or down when the threshold of an alarm is breached.
Dynamic scaling policies are reactive. They allow you to track a specific CloudWatch metric and to take an action when the CloudWatch alarm is triggered. Predictive scaling policies are used in combination with dynamic scaling policies when your application demand changes rapidly but with a recurring pattern or when your application instances require a longer time to initialize.
Scheduled scaling helps you to set up your own scaling schedule according to predictable load changes. For example, let’s say that every week the traffic to your web application starts to increase on Wednesday, remains high on Thursday, and starts to decrease on Friday. You can configure a schedule for Amazon EC2 Auto Scaling to increase capacity on Wednesday and decrease capacity on Friday.
Predictive scaling uses machine learning to predict capacity requirements based on historical data from CloudWatch. The machine learning algorithm consumes the available historical data and calculates capacity that best fits the historical load pattern, and then continuously learns based on new data to make future forecasts more accurate.