Use Distribution Segments to target multiple Capacity Reservation types
Use distribution segments to configure your Auto Scaling group to consume multiple Capacity Reservation types – On-Demand Capacity Reservations, Capacity Blocks for ML, and interruptible Capacity Reservations – with priority ordering. You target these reservation types by pointing your Auto Scaling group at a Capacity Reservation Resource Group that contains a mix of different Capacity Reservations.
When you configure distribution segments, Auto Scaling launches instances across the reservation types in the priority order you specify, with optional fallback to On-Demand capacity.
How Auto Scaling distributes instances across market options
Auto Scaling distributes launched instances across different market options based on your mixed instances policy configuration.
On-Demand and Spot distribution
You can distribute instances between On-Demand and Spot capacity using the
OnDemandBaseCapacity and
OnDemandPercentageAboveBaseCapacity fields on your mixed instances
policy. The following example launches the first 2 instances as On-Demand, then 25
percent of the remaining instances as On-Demand and the remaining as Spot:
{ "InstancesDistribution": { "OnDemandBaseCapacity":2, "OnDemandPercentageAboveBaseCapacity":25} }
Distribution with distribution segments
A distribution segment is a configuration on your Auto Scaling group that contains a list of
capacity types to prioritize in order. distribution segments are set on the
DistributionSegments field of your mixed instances policy.
Auto Scaling currently supports only one distribution segment per Auto Scaling group. All Auto Scaling group
capacity is distributed across the target capacity types
(TargetCapacityTypes) in that segment.
The valid values for TargetCapacityTypes are:
-
on-demand-capacity-reservation– On-Demand Capacity Reservations -
capacity-block– Capacity Blocks for ML -
interruptible-capacity-reservation– interruptible Capacity Reservations -
on-demand– On-Demand capacity
The order of the list determines how Auto Scaling distributes launched instances. Auto Scaling attempts to consume capacity in the order in which the types are listed. When a particular capacity type is unavailable, Auto Scaling skips that type and moves on to the next one.
The following example launches instances as On-Demand Capacity Reservation-backed first, then as Capacity Block-backed, then as interruptible Capacity Reservation-backed, and finally as On-Demand if reserved capacity is insufficient:
{ "InstancesDistribution": { "DistributionSegments": [ { "TargetCapacityTypes": [ "on-demand-capacity-reservation", "capacity-block", "interruptible-capacity-reservation", "on-demand" ] } ] } }
If you include on-demand in the list, Auto Scaling falls back to On-Demand
capacity when reserved capacity is unavailable. If you omit on-demand,
instances fail to launch when reserved capacity is unavailable. If you include
on-demand, it must be the last entry in the list.
Note
Spot capacity is not supported as a target capacity type at this time.
Prerequisites
Before you can configure distribution segments on your Auto Scaling group, you must create the Capacity Reservations that you want to consume and the Capacity Reservation Resource Group that contains them.
To create a Capacity Reservation, see one of the following in the Amazon EC2 User Guide:
-
Create a Capacity Reservation – for On-Demand Capacity Reservations
-
Find and purchase Capacity Blocks – for Capacity Blocks
-
Interruptible Capacity Reservations for capacity owners – for interruptible Capacity Reservations
To create a Capacity Reservation Resource Group that contains a mix of different Capacity Reservations, see Capacity Reservation Resource Groups in the Amazon EC2 User Guide.
Configure your Auto Scaling group to use distribution segments
To configure your Auto Scaling group to use distribution segments, add them to your mixed instances policy and set the Capacity Reservation Resource Group ARN as the target on your Capacity Reservation specification.
Auto Scaling attempts to launch instances in the priority order of the capacity types, and
within each capacity type, in the order of instance types listed in your launch template
Overrides.
Migrate to and from distribution segments
You can migrate an existing Auto Scaling group to use distribution segments, and migrate back to a standard configuration when needed. In all migration scenarios, existing instances continue running. New launches follow the updated configuration.
Migrate a mixed instances group to use distribution segments
To migrate an existing mixed instances group to use distribution segments, use one of the following
methods. Auto Scaling automatically clears OnDemandBaseCapacity and
OnDemandPercentageAboveBaseCapacity when you add distribution segments.
Migrate away from distribution segments
To migrate back to a standard mixed instances group, use one of the following methods.
Note
You can also migrate to and from distribution segments using an instance refresh with the
--desired-configuration parameter.
Scale-in behavior with distribution segments
When your Auto Scaling group scales in, Auto Scaling terminates instances in the opposite order of your
TargetCapacityTypes. On-Demand instances are terminated first, followed
by instances of the lowest-priority capacity type, and so on up to the highest-priority
capacity type.
For example, with TargetCapacityTypes set to
["on-demand-capacity-reservation", "capacity-block",
"interruptible-capacity-reservation", "on-demand"], Auto Scaling terminates instances
in the following order during scale in:
-
On-Demand
-
interruptible Capacity Reservation-backed
-
Capacity Block-backed
-
On-Demand Capacity Reservation-backed
If you update your distribution segments to remove a reservation type, existing instances of that removed type are terminated before any instance whose type is still in the list.
Considerations
-
Capacity Reservation preference – Only
defaultis supported when configuring distribution segments. For more information, see Capacity Reservation preference. -
On-Demand allocation strategy – Only
prioritizedis supported when you configure distribution segments. -
Warm pools – Warm pools are not supported with distribution segments.
-
Spot capacity – Spot capacity is not supported as a target capacity type in distribution segments.