After reviewing the differences between Scaling policies, you have decided to go with Predictive Scaling because it can help you scale faster by launching capacity in advance of forecasted load, compared to using only dynamic scaling, which is reactive in nature. Predictive scaling can also potentially save you money on your EC2 bill by helping you avoid the need to overprovision capacity.
Predictive scaling requires 24 hours of metric history before it can generate forecasts. Predictive scaling finds patterns in CloudWatch metric data from the previous 14 days to create an hourly forecast for the next 48 hours. Forecast data is updated daily based on the most recent CloudWatch metric data.
To generate forecasts, the predictive scaling algorithm needs three metrics as input:
Read more about predictive scaling in the New – Predictive Scaling for EC2, Powered by Machine Learning blog post.
A core assumption of predictive scaling is that the Auto Scaling group is homogenous and all instances are of equal capacity. In this workshop you use t3.micro, a single instance type, in the Auto Scaling group. If your actual workload uses Auto Scaling groups with multiple instance types (mixed instance groups), then use caution when creating predictive scaling policies. Predictive scaling with mixed instance groups can forecast capacity inaccurately and launch instance types of unequal capacity.
Predictive scaling can be created in “forecast only” mode so that you can evaluate the forecast before predictive scaling starts actively scaling capacity. You can view the forecast and recent metric data from CloudWatch in graph form from the Amazon EC2 Auto Scaling console. When you are ready to start scaling with predictive scaling, you can switch the policy from “forecast only” mode to “forecast and scale” mode. After you switch to “forecast and scale” mode, your Auto Scaling group starts scaling based on the forecast.
In this step, you are going to configure predictive scaling in “forecast only” mode for your Auto Scaling group.
cat <<EoF > predictive-scaling-policy-cpu.json
aws autoscaling put-scaling-policy \
--auto-scaling-group-name "ec2-workshop-asg" \
--policy-name "CPUUtilizationpolicy" \
--policy-type "PredictiveScaling" \
Note that Predictive scaling forecast shows no data as it requires 24 hours of metric history before it can generate forecasts. Therefore in next chapter, you use CloudWatch custom metrics to create a history of data that can be used for forecasting by predictive scaling policy.