How does the Cost Optimizer handle On-Demand and Spot instances?

Last updated: August 12, 2026

Context

When using the Cost Optimizer with both On-Demand and Spot capacity enabled, you may want to understand how instance selection works, what happens during a Spot interruption, and how to best configure your workloads to handle these scenarios.

Answer

When both On-Demand and Spot capacity types are enabled, the Cost Optimizer selects the cheapest available option for the best-fit instance type and size for your workloads:

  • Spot instances are preferred when available in the required instance families and sizes, as they are typically cheaper.

  • On-Demand instances are used as a fallback when suitable Spot capacity is not available.

There is no active rotation between Spot and On-Demand. The optimizer dynamically chooses the most cost-effective option at the time of provisioning, without guaranteeing either type.

What happens during a Spot interruption?
If a Spot instance is interrupted, the optimizer will spin up a replacement instance — whichever option is the most cost-effective at that moment, which could be Spot again or On-Demand.

Best practices for handling interruptions:
Because Spot instances can be interrupted at any time, it is important to ensure your applications can handle terminations gracefully. We recommend enabling Zero Downtime Deployments, which ensures your application handles terminations of any type gracefully, minimizing disruption to your workloads.