When I try to launch an instance in my Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group, I get an “InsufficientInstanceCapacity” or “UnfulfillableCapacity” error.
Short description
To launch an instance in your EC2 Auto Scaling group, you must have enough available instance types. These instance types must also be in the relevant Availability Zone for either On-Demand Instances or Spot Instances. If there's insufficient EC2 instance capacity in the Availability Zone for the instance types that you selected, then you might get a launch failure. To decrease the chance of a launch failure in your EC2 Auto Scaling group, implement these best practices.
Resolution
Specify more instance types
Specify multiple instance types in EC2 Auto Scaling groups. This provides more options for you to launch an instance.
Specify multiple instance types in the EC2 Auto Scaling group's instance overrides. It's a best practice to specify at least 10 different instance types or families. The more instance types or families that you specify, the less likely you are to experience launch failure.
Increase the range of instance types
To widen the range of instance types that are available to launch, use attribute-based instance selection.
You can specify attributes such as vCPU number or memory, or other attributes such as instance family or generations.
Preview your matching instance types through the Auto Scaling Group when you specify the instance attributes. Or, use the GetInstanceTypesFromInstanceRequirements API in the AWS Command Line Interface (AWS CLI).
Note: If you receive errors when you run AWS CLI commands, see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.
By default, attribute-based instance type selection prevents the selection of the most expensive instances. To configure how EC2 Auto Scaling limits instances by price, use the price protection attribute.
Increase active Availability Zones
Add and include more or all the Availability Zones in the AWS Region for the Auto Scaling group. This spreads out your instances across Availability Zones, which increases the overall availability of instance types.
Reserve specific instance types
To reserve specific instance types in an Availability Zone, use OnDemand Capacity Reservations.
Specify an On-Demand base capacity
To maintain a base number of On-Demand Instances, specify an On-Demand base capacity. On-Demand base capacity gives you a set number of On-Demand Instances in your EC2 Auto Scaling group. This makes sure that you have the minimum resources for application availability, even when your Spot Instances are unavailable.
When there's insufficient Spot Instance availability, your Auto Scaling Group tries repeatedly to launch Spot instances from different Spot capacity pools.
Assess your current allocation strategy
To reduce the risk of Spot Instance interruption that might lead to launch failure, specify a Spot Instance allocation strategy. Specify the best strategy for your use case:
- The price-capacity-optimized allocation strategy takes into account both the price and availability of the instance type in the Availability Zone. This is a best practice to reduce interruption rates.
- The lowest-price allocation strategy takes into account only the cost of an instance. It doesn't take into account the overall availability of the instance type in the Availability Zone. This might lead to higher interruption rates.
Use Capacity Rebalancing
To receive notifications when there's an elevated risk of Spot Instance interruption, use Capacity Rebalancing. Use this to proactively replace your capacity with an instance that has less risk of interruption.
Note: Capacity Rebalancing might not work for all use cases, and in some cases it might cause issues for your allocation strategy. If this method doesn't resolve your issue, then evaluate the considerations for Capacity Rebalancing in relation to your use case.
Related Information
How do I troubleshoot InsufficientInstanceCapacity errors when starting or launching an EC2 instance?
Why am I receiving a "no Spot capacity available" error when trying to launch an Amazon EC2 Spot Instance?