Requesting Spot Instances for fault-tolerant and flexible applications - Amazon EC2 Auto Scaling

Requesting Spot Instances for fault-tolerant and flexible applications

Amazon EC2 Spot Instances are spare capacity available at steep discounts compared to the EC2 On-Demand price. You can use Spot Instances for various fault-tolerant and flexible applications.

This topic describes how to launch only Spot Instances in your Auto Scaling group by specifying settings in a launch configuration, rather than in the Auto Scaling group itself. The information in this topic also applies to Auto Scaling groups that request Spot Instances with a launch template.


Spot Instances are typically used to supplement On-Demand Instances. For this scenario, 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 request to launch Spot Instances only after launching a certain number of On-Demand Instances and then continue to launch some combination of On-Demand Instances and Spot Instances as the group scales. 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. 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, the Amazon EC2 Spot service 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 the specified 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 of the Availability Zones. For more information, see Rebalancing activities.

  • Spot Instance termination. When scaling or performing health checks, Amazon EC2 Auto Scaling can terminate or replace Spot Instances in the same way that it can terminate or replace On-Demand Instances. For information about how Amazon EC2 Auto Scaling uses termination policies to select instances for termination during scale in, see Controlling which Auto Scaling instances terminate during scale in.