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.

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.

Important

The information in this section is applicable to configuring a Spot Instance purchase option as part of a launch configuration or launch template. To launch both On-Demand Instances and Spot Instances in your Auto Scaling group, see Using Multiple Instance Types and Purchase Options instead.

When you create a launch configuration or 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 template.

  • Changing your maximum price. You must create a launch configuration or 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, so it is automatically be associated with the Auto Scaling group. The existing instances continue to run as long as the maximum price specified in the launch configuration or template used for those instances is higher than the current Spot market price.

  • Spot market price and your maximum price. If the market price for Spot Instances rises above your maximum price for a running instance in your Auto Scaling group, Amazon EC2 terminates your instance. If the Spot market price is within your maximum price, whether your request is fulfilled depends on Spot Instance capacity.

  • 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 market 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, 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, 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 just as it can terminate or replace On-Demand Instances. For more information, see Controlling Which Auto Scaling Instances Terminate During Scale In.