On-Demand vs Reserved vs Spot in AWS: Key Differences and Usage
On-Demand instances let you pay for compute capacity by the hour or second with no long-term commitment. Reserved instances require a one- or three-year commitment for a lower price, ideal for steady workloads. Spot instances offer the lowest cost by using spare capacity but can be interrupted by AWS with little notice.Quick Comparison
This table summarizes the main differences between On-Demand, Reserved, and Spot instances in AWS.
| Factor | On-Demand | Reserved | Spot |
|---|---|---|---|
| Pricing Model | Pay per use, no commitment | Pay upfront or monthly for 1-3 years | Use spare capacity at low cost |
| Cost | Highest | Lower than On-Demand | Lowest |
| Availability | Always available | Capacity reserved for you | Available when spare capacity exists |
| Use Case | Short-term, unpredictable workloads | Steady, predictable workloads | Flexible, fault-tolerant workloads |
| Interruption Risk | None | None | Can be interrupted anytime with 2-minute warning |
| Commitment | None | 1 or 3 years | None |
Key Differences
On-Demand instances provide the most flexibility by charging you only for what you use without any upfront commitment. This makes them perfect for testing, development, or unpredictable workloads where you cannot predict usage.
Reserved instances require you to commit to a 1- or 3-year term, either paying upfront or monthly. In exchange, you get a significant discount compared to On-Demand pricing. This is best for applications with steady usage where you want to save money.
Spot instances let you use AWS's unused capacity at a steep discount. However, AWS can reclaim these instances with a short notice (usually 2 minutes), so they are suitable only for flexible, fault-tolerant workloads like batch jobs or big data processing.
Code Comparison
Here is an example AWS CLI command to launch an On-Demand EC2 instance.
aws ec2 run-instances --image-id ami-0abcdef1234567890 --count 1 --instance-type t3.micro --key-name MyKeyPair --security-group-ids sg-0123456789abcdef0 --subnet-id subnet-6e7f829e
Reserved Equivalent
To launch a Reserved instance, you first purchase the reservation in AWS Management Console or CLI, then launch the instance normally. Here is how to purchase a Reserved instance using AWS CLI.
aws ec2 purchase-reserved-instances-offering --reserved-instances-offering-id e3f1a2b3-4c5d-6e7f-8901-23456789abcd --instance-count 1
When to Use Which
Choose On-Demand when you need maximum flexibility without upfront costs, such as for short-term or unpredictable workloads. Choose Reserved when you have steady, predictable usage and want to save money with a long-term commitment. Choose Spot when your workloads are fault-tolerant and can handle interruptions, allowing you to benefit from the lowest prices.