Skip to content
tezvyn:
Menu

Differences between on-demand, reserved, and spot EC2 instances?

Source: docs.aws.amazon.comEasyHow cards are made

Differences between on-demand, reserved, and spot EC2 instances?

Tests cost-reliability-commitment tradeoffs for ML infrastructure. Good answers map on-demand to experiments, reserved for production training, and spot to fault-tolerant batch jobs. Red flag: spot for real-time serving or skipping reserved capacity analysis.

What's really being asked

This question evaluates whether you understand EC2 purchasing models beyond their names. The interviewer wants to see if you can balance cost, availability guarantees, and operational complexity when provisioning infrastructure for machine learning. It also reveals whether you think about workload characteristics like fault tolerance, duration, and criticality before picking a compute tier.

The full answer

First, define the three models in terms of commitment and interruption risk. On-demand provides instant capacity with no commitment and highest per-second cost, making it ideal for short-lived or unpredictable workloads like exploratory data analysis and prototyping. Reserved instances require a one or three year commitment to specific instance families in exchange for a significantly lower hourly rate, which suits always-on or predictable pipelines such as critical production model training that runs on a fixed schedule. Spot instances let you use spare EC2 capacity at a steep discount but with a two-minute interruption warning when AWS reclaims the capacity, so they fit only fault-tolerant distributed training or batch inference jobs that checkpoint progress regularly. Second, map each to concrete ML scenarios: on-demand for Jupyter notebooks and ad-hoc experiments, reserved for recurring retraining or persistent inference endpoints that must stay up, and spot for large-scale offline batch inference or hyperparameter search where individual node failure does not kill the job. Third, mention hybrid strategies, such as running a training cluster with a reserved primary node for stability and spot workers for elasticity, or using on-demand as a fallback during spot droughts.

The mistakes people make

Recommending spot instances for real-time model serving or low-latency inference because the cost is low; this ignores the two-minute interruption window and potential latency spikes. Claiming reserved instances are always cheaper without acknowledging the lock-in risk or the need for steady-state utilization to break even. Treating on-demand as a default for everything and dismissing reserved or spot options entirely. Failing to mention checkpointing or retry logic when proposing spot for training workloads.

What usually comes next

How would you handle a spot interruption during a multi-hour training run? When does a Savings Plan make more sense than a reserved instance? How do you automate the fallback from spot to on-demand in a Kubernetes cluster? What metrics would you track to decide if a reserved instance purchase is justified?

A concrete example

A team runs a nightly four-hour deep learning training job that is not time-critical but must complete before morning dashboards refresh. They launch the job on a cluster of GPU spot instances with checkpointing to S3 every epoch. If spot capacity is interrupted, the training script catches the termination signal, saves the latest checkpoint, and the orchestrator reschedules the job on fresh spot or on-demand capacity. Over a month, this cuts compute spend by roughly half compared to on-demand while still meeting the SLA, whereas the production real-time inference API sits on reserved instances to guarantee uptime.

Interview question

Which machine learning workload is best suited for Spot instances given their cost and interruption characteristics?

  • a.Training a distributed job that checkpoints progress and tolerates individual node failuresCorrect
  • b.Hosting a real-time model API that requires consistent sub-100ms latency
  • c.Running a persistent inference endpoint that must remain available 24/7
  • d.Prototyping models in an interactive Jupyter notebook environment
Why?

Spot instances offer steep discounts but can be reclaimed with only a two-minute warning, so they are appropriate only for fault-tolerant workloads that checkpoint progress regularly. Hosting a real-time API is a tempting but dangerous choice because interruptions would directly violate latency and availability requirements.

Just read this? Test yourself on what you have been reading.

Read the original → docs.aws.amazon.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles