Target tracking scaling: Scale Spot Fleet by targeting a value for a specific metric
With target tracking scaling, you create a target tracking scaling policy by selecting a metric and setting a target value. Spot Fleet then creates and manages the CloudWatch alarms that trigger the scaling policy, and calculates the scaling adjustment based on the chosen metric and target value. The scaling policy adjusts capacity by adding or removing instances as needed to keep the metric at, or close to, the specified target value. A target tracking policy not only keeps the metric close to the target value, but also adjusts to the fluctuations in the metric due to a fluctuating load pattern and minimizes rapid capacity fluctuations.
You can create multiple target tracking scaling policies for a Spot Fleet, provided each policy uses a different metric. The fleet scales based on the policy that specifies the largest fleet capacity. This allows you to cover multiple scenarios to ensure sufficient capacity for your application workloads.
To ensure application availability, the fleet scales out proportionally to the metric as fast as it can, but scales in more gradually.
When a Spot Fleet terminates a Spot Instance because the target capacity was decreased, the instance receives a Spot Instance interruption notice.
Note
Do not edit or delete the CloudWatch alarms that Spot Fleet manages for a target tracking scaling policy. Spot Fleet deletes the alarms automatically when you delete the target tracking scaling policy.
Prerequisites
-
The Spot Fleet request must have a request type of
maintain
. Automatic scaling is not supported for requests of typerequest
. -
Configure the IAM permissions required for Spot Fleet automatic scaling.
-
Review the Considerations.
To configure a target tracking policy (console)
-
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
In the navigation pane, choose Spot Requests.
-
Select your Spot Fleet request.
-
Choose the Auto Scaling tab near the bottom of the screen. If you selected the link for your Spot Fleet, there is no tab; instead, scroll down to the Auto Scaling section.
-
If automatic scaling is not configured, choose Configure.
-
Use Scale capacity between to set the minimum and maximum capacity for your fleet. Automatic scaling does not scale your fleet below the minimum capacity or above the maximum capacity.
-
For Policy name, enter a name for the policy.
-
Choose a Target metric.
-
Enter a Target value for the metric.
-
For Cooldown period, specify a new value (in seconds) or keep the default.
-
(Optional) To omit creating a scale-in policy based on the current configuration, select Disable scale-in. You can create a scale-in policy using a different configuration.
-
Choose Save.
To configure a target tracking policy using the AWS CLI
-
Register the Spot Fleet request as a scalable target using the register-scalable-target command.
-
Create a scaling policy using the put-scaling-policy command.