EC2 Purchasing Options Flashcards
What are the four purchasing options for EC2 instances?
- On-demand instances
- Reserved instances
- Spot instances
- Dedicated host
If you want to save money on EC2 instances, what are your options? When would you want to use each option?
Reserved instance: up to 75% cheaper, but you reserve it for either one or three years (three years gives you a bigger discount).
Spot instances: The cheapest option - up to 90% discount. The catch is that you “bid” on them, and you can lose the instance if your maximum price is less than the current spot price.
Spot instances work well if you only need it for a short time (to run some kind of regular task) and don’t care if it disappears.
If you need something long-term, or on a guaranteed schedule, a reserved instance is probably the better choice.
Do you need to pay for reserved instances upfront?
No, but you have the option to pay upfront, no upfront, or partially upfront. Paying upfront (or partially upfront) usually means a better discount.
How long do you need to buy a reserved instance for?
It has to be for either one or three years, nothing in between.
AWS actually has a “reserved instance marketplace” where you can sell your remaining instance time to a 3rd party, so this is an option if you want a different time period.
What if I know that I want a reserved instance, but I’m worried that my needs for that instance could change over time?
You lose some of the discount, but you can choose a “convertible” reserved instance, which allows you to change the instance type (e.g. t2 to t3).
Otherwise, you can make some changes (like changing the size of the instance, moving to a new AZ) but can’t change the instance type.
I’m running insane Oracle software that has a per-core licensing model, so I need my own physical machine. What EC2 type should I get?
A dedicated host. It’s an physical server that’s dedicated to you.
A dedicated host can also be useful if you have regulatory compliance requirements that make you need a dedicated server.
What if I want a reserved instance, but it doesn’t need to be running all the time?
You can get a “scheduled” reserved instance. Still needs to be at least a year, but runs on a schedule so it’s cheaper.
e.g. every Thursday between 3 and 6
I want a short-lived, ephemeral, on-demand EC2 instance. A spot instance would be perfect, but I’m running a task that takes three hours - losing the instance and having to restart is pretty frustrating. Is there some way to make sure that my spot instance won’t be lost?
Yes! If you have a defined-duration workload, you can purchase a “spot block” for between 1-6 hours. It’s about 30-45% cheaper than on-demand… you can still lose your instance, but only in rare circumstances.
This is a good option for computationally-intensive jobs that have a predictable duration, like encoding / rendering / modeling / batch processing / CI.
What are spot fleets?
A set of spot instances that try to meet your target capacity with price constraints. It can optionally include on-demand instances as well.
The pools that these spot instances are chose from are decided by the spot fleet allocation strategy you choose.
What are the three spot fleet allocation strategies?
lowest price: picks whatever instances are cheapest. This is the default.
diversified: picks instances from different pools - this is sometimes better for availability and long workloads
capacity optimized: The Spot Instances come from the pools with optimal capacity for the number of instances that are launching. What this effectively means is that these instances are less likely to be terminated (because their pools are less likely to run out of instances) - you will likely pay more, but it could be more cost effective if you’re doing work with a higher cost of interruption.