Amazon EC2 Auto Scaling
User Guide

Launching Spot Instances in Your Auto Scaling Group

Spot Instances are a cost-effective choice compared to On-Demand Instances, if you can be flexible about when your applications run and if your applications can be interrupted. This topic describes how to launch only Spot Instances in your Auto Scaling Group by specifying settings in a launch configuration or launch template, rather than in the Auto Scaling group itself.

Important

You can specify the same settings that are used to launch Spot Instances as part of the settings of an Auto Scaling group. When you specify the settings as part of the Auto Scaling group, you can specify additional options. For example, you can specify whether to launch only Spot Instances, or a combination of both On-Demand Instances and Spot Instances. For more information, see Auto Scaling Groups with Multiple Instance Types and Purchase Options.

Before launching Spot Instances using Amazon EC2 Auto Scaling, we recommend that you become familiar with launching and managing Spot Instances using Amazon EC2. For more information, see Spot Instances in the Amazon EC2 User Guide for Linux Instances.

When you create a launch configuration or launch template to launch Spot Instances instead of On-Demand Instances, keep the following considerations in mind:

  • Setting your maximum price. You set the maximum price you are willing to pay as part of the launch configuration or launch template. If the Spot price is within your maximum price, whether your request is fulfilled depends on Spot Instance capacity. You pay only the Spot price for the Spot Instances that you launch. If the price for Spot Instances rises above your maximum price for a running instance in your Auto Scaling group, Amazon EC2 terminates your instance. For more information, see Pricing and Savings in the Amazon EC2 User Guide for Linux Instances.

  • Changing your maximum price. You must create a launch configuration or launch template version with the new price. With a new launch configuration, you must associate it with your Auto Scaling group. With a launch template, you can configure the Auto Scaling group to use the default template or the latest version of the template. That way, it is automatically associated with the Auto Scaling group. The existing instances continue to run as long as the maximum price specified in the launch configuration or launch template used for those instances is higher than the current Spot price.

  • Maintaining your Spot Instances. When your Spot Instance is terminated, the Auto Scaling group attempts to launch a replacement instance to maintain the desired capacity for the group. If your maximum price is higher than the Spot price, then it launches a Spot Instance. Otherwise (or if the request is unsuccessful), it keeps trying.

  • Balancing across Availability Zones. If you specify multiple Availability Zones, Amazon EC2 Auto Scaling distributes the Spot requests across these Availability Zones. If your maximum price is too low in one Availability Zone for any requests to be fulfilled, Amazon EC2 Auto Scaling checks whether requests were fulfilled in the other zones. If so, Amazon EC2 Auto Scaling cancels the requests that failed and redistributes them across the Availability Zones that have requests fulfilled. If the price in an Availability Zone with no fulfilled requests drops enough that future requests succeed, Amazon EC2 Auto Scaling rebalances across all the Availability Zones. For more information, see Rebalancing Activities.

  • Spot Instance termination. Amazon EC2 Auto Scaling can terminate or replace Spot Instances in the same way that it can terminate or replace On-Demand Instances. For more information, see Controlling Which Auto Scaling Instances Terminate During Scale In.

  • Spot interruption notices. You can use Spot Instance interruption notices to monitor the status of your Spot Instances. For example, you can set up a rule in Amazon CloudWatch Events that automatically sends the EC2 Spot two-minute warning to an Amazon SNS topic, an AWS Lambda function, or another target. For more information, see Spot Instance Interruption Notices in the Amazon EC2 User Guide for Linux Instances and the Amazon CloudWatch Events User Guide.