Allocation strategies for Spot Instances
Your launch configuration determines all the possible Spot capacity pools (instance types and Availability Zones) from which Spot Fleet can launch Spot Instances. However, when launching instances, Spot Fleet uses the allocation strategy that you specify to pick the specific pools from all your possible pools.
Allocation strategies
You can specify one of the following allocation strategies for your Spot Instances:
priceCapacityOptimized
(recommended)-
Spot Fleet identifies the pools with the highest capacity availability for the number of instances that are launching. This means that we will request Spot Instances from the pools that we believe have the lowest chance of interruption in the near term. Spot Fleet then requests Spot Instances from the lowest priced of these pools.
The
priceCapacityOptimized
allocation strategy is the best choice for most Spot workloads, such as stateless containerized applications, microservices, web applications, data and analytics jobs, and batch processing. capacityOptimized
-
Spot Fleet identifies the pools with the highest capacity availability for the number of instances that are launching. This means that we will request Spot Instances from the pools that we believe have the lowest chance of interruption in the near term. You can optionally set a priority for each instance type in your fleet using
capacityOptimizedPrioritized
. Spot Fleet optimizes for capacity first, but honors instance type priorities on a best-effort basis.With Spot Instances, pricing changes slowly over time based on long-term trends in supply and demand, but capacity fluctuates in real time. The
capacityOptimized
strategy automatically launches Spot Instances into the most available pools by looking at real-time capacity data and predicting which are the most available. This works well for workloads that may have a higher cost of interruption associated with restarting work, such as long Continuous Integration (CI), image and media rendering, Deep Learning, and High Performance Compute (HPC) workloads that may have a higher cost of interruption associated with restarting work. By offering the possibility of fewer interruptions, thecapacityOptimized
strategy can lower the overall cost of your workload.Alternatively, you can use the
capacityOptimizedPrioritized
allocation strategy with a priority parameter to order instance types from highest to lowest priority. You can set the same priority for different instance types. Spot Fleet will optimize for capacity first, but will honor instance type priorities on a best-effort basis (for example, if honoring the priorities will not significantly affect Spot Fleet's ability to provision optimal capacity). This is a good option for workloads where the possibility of disruption must be minimized and the preference for certain instance types matters. Using priorities is supported only if your fleet uses a launch template. Note that when you set the priority forcapacityOptimizedPrioritized
, the same priority is also applied to your On-Demand Instances if the On-DemandAllocationStrategy
is set toprioritized
. diversified
-
The Spot Instances are distributed across all pools.
lowestPrice
-
The Spot Instances come from the lowest priced pool that has available capacity. This is the default strategy. However, we recommend that you override the default by specifying the
priceCapacityOptimized
allocation strategy.If the lowest priced pool doesn't have available capacity, the Spot Instances come from the next lowest priced pool that has available capacity.
If a pool runs out of capacity before fulfilling your desired capacity, Spot Fleet will continue to fulfill your request by drawing from the next lowest priced pool. To ensure that your desired capacity is met, you might receive Spot Instances from several pools.
Because this strategy only considers instance price and not capacity availability, it might lead to high interruption rates.
InstancePoolsToUseCount
-
The number of Spot pools across which to allocate your target Spot capacity. Valid only when the allocation strategy is set to
lowestPrice
. Spot Fleet selects the lowest priced Spot pools and evenly allocates your target Spot capacity across the number of Spot pools that you specify.Note that Spot Fleet attempts to draw Spot Instances from the number of pools that you specify on a best effort basis. If a pool runs out of Spot capacity before fulfilling your target capacity, Spot Fleet will continue to fulfill your request by drawing from the next lowest priced pool. To ensure that your target capacity is met, you might receive Spot Instances from more than the number of pools that you specified. Similarly, if most of the pools have no Spot capacity, you might receive your full target capacity from fewer than the number of pools that you specified.
Choose an appropriate allocation strategy
You can optimize your fleet for your use case by choosing the appropriate Spot
allocation strategy. For On-Demand Instance target capacity, Spot Fleet always selects the least
expensive instance type based on the public On-Demand price, while following the
allocation strategy—either priceCapacityOptimized
,
capacityOptimized
, diversified
, or
lowestPrice
—for Spot Instances.
Balance lowest price and capacity availability
To balance the trade-offs between the lowest priced Spot capacity pools
and the Spot capacity pools with the highest capacity availability, we
recommend that you use the priceCapacityOptimized
allocation
strategy. This strategy makes decisions about which pools to request Spot Instances
from based on both the price of the pools and the capacity availability of
Spot Instances in those pools. This means that we will request Spot Instances from the pools
that we believe have the lowest chance of interruption in the near term,
while still taking price into consideration.
If your fleet runs resilient and stateless workloads, including
containerized applications, microservices, web applications, data and
analytics jobs, and batch processing, then use the
priceCapacityOptimized
allocation strategy for optimal cost
savings and capacity availability.
If your fleet runs workloads that might have a higher cost of interruption
associated with restarting work, then you should implement checkpointing so
that applications can restart from that point if they're interrupted. By
using checkpointing, you make the priceCapacityOptimized
allocation strategy a good fit for these workloads because it allocates
capacity from the lowest priced pools that also offer a low Spot Instance
interruption rate.
For an example configuration that uses the
priceCapacityOptimized
allocation strategy, see Example 10: Launch Spot Instances in a capacity-optimized fleet
with priorities.
When workloads have a high cost of interruption
You can optionally use the capacityOptimized
strategy if you
run workloads that either use similarly priced instance types, or where the
cost of interruption is so significant that any cost saving is inadequate in
comparison to a marginal increase in interruptions. This strategy allocates
capacity from the most available Spot capacity pools that offer the
possibility of fewer interruptions, which can lower the overall cost of your
workload. For an example configuration that uses the
capacityOptimized
allocation strategy, see Example 8: Configure Capacity Rebalancing to launch
replacement Spot Instances.
When the possibility of interruptions must be minimized but the preference
for certain instance types matters, you can express your pool priorities by
using the capacityOptimizedPrioritized
allocation strategy and
then setting the order of instance types to use from highest to lowest
priority. For an example configuration, see Example 9: Launch Spot Instances in a capacity-optimized
fleet.
Note that using priorities is supported only if your fleet uses a launch
template. Also note that when you set priorities for
capacityOptimizedPrioritized
, the same priorities are also
applied to your On-Demand Instances if the On-Demand
AllocationStrategy
is set to prioritized
.
When your workload is time flexible and capacity availability is not a factor
If your fleet is small or runs for a short time, you can use
priceCapacityOptimized
to maximize cost savings while still
considering capacity availability.
If your workload is time flexible and capacity availability is not a
factor, you can optionally use the lowestPrice
allocation
strategy to maximize cost savings. Note, however, that because the
lowestPrice
allocation strategy only considers instance
price and not capacity availability, it might lead to high Spot Instance interruption
rates.
When your fleet is large or runs for a long time
If your fleet is large or runs for a long time, you can improve the
availability of your fleet by distributing the Spot Instances across multiple pools
using the diversified
strategy. For example, if your Spot Fleet
specifies 10 pools and a target capacity of 100 instances, the fleet
launches 10 Spot Instances in each pool. If the Spot price for one pool exceeds your
maximum price for this pool, only 10% of your fleet is affected. Using this
strategy also makes your fleet less sensitive to increases in the Spot price
in any one pool over time. With the diversified
strategy, the
Spot Fleet does not launch Spot Instances into any pools with a Spot price that is equal to
or higher than the On-Demand
price
To create an inexpensive and diversified fleet, use the
lowestPrice
strategy in combination with
InstancePoolsToUseCount
. For example, if your target
capacity is 10 Spot Instances, and you specify 2 Spot capacity pools (for
InstancePoolsToUseCount
), Spot Fleet will draw on the two lowest
priced pools to fulfill your Spot capacity.
You can use a low or high number of Spot capacity pools across which to
allocate your Spot Instances. For example, if you run batch processing, we recommend
specifying a low number of Spot capacity pools (for example,
InstancePoolsToUseCount=2
) to ensure that your queue always
has compute capacity while maximizing savings. If you run a web service, we
recommend specifying a high number of Spot capacity pools (for example,
InstancePoolsToUseCount=10
) to minimize the impact if a
Spot capacity pool becomes temporarily unavailable.
Note that Spot Fleet attempts to draw Spot Instances from the number of pools that you specify on a best effort basis. If a pool runs out of Spot capacity before fulfilling your target capacity, Spot Fleet will continue to fulfill your request by drawing from the next lowest priced pool. To ensure that your target capacity is met, you might receive Spot Instances from more than the number of pools that you specified. Similarly, if most of the pools have no Spot capacity, you might receive your full target capacity from fewer than the number of pools that you specified.
Maintain target capacity
After Spot Instances are terminated due to a change in the Spot price or available
capacity of a Spot capacity pool, a Spot Fleet of type maintain
launches
replacement Spot Instances. The allocation strategy determines the pools from which the
replacement instances are launched, as follows:
-
If the allocation strategy is
priceCapacityOptimized
, the fleet launches replacement instances in the pools that have the most Spot Instance capacity availability while also taking price into consideration and identifying lowest priced pools with high capacity availability. -
If the allocation strategy is
capacityOptimized
, the fleet launches replacement instances in the pools that have the most Spot Instance capacity availability. -
If the allocation strategy is
diversified
, the fleet distributes the replacement Spot Instances across the remaining pools. -
If the allocation strategy is
lowestPrice
, the fleet launches replacement instances in the pool where the Spot price is currently the lowest. -
If the allocation strategy is
lowestPrice
in combination withInstancePoolsToUseCount
, the fleet selects the Spot capacity pools with the lowest price and launches Spot Instances across the number of Spot capacity pools that you specify.