Autoscaling and Spot Instances
Elasticity you can actually cash
Autoscaling matches serving and training capacity to actual demand; spot instances buy preemptible capacity at a deep discount. Together they cut idle money — if interrupt tolerance is engineered in.
What you will learn
- Right-size serving capacity with autoscaling policies
- Use spot/preemptible capacity for interrupt-tolerant work
- Engineer checkpoint-and-resume against evictions
What is this?
Autoscaling elastically matches capacity — serving replicas to traffic, training workers to queue depth — while spot instances offer borderline-free preemptible compute. Savings come from killing idle money and buying discounted metal, with checkpoint-and-resume as the insurance policy.
Why do you need it?
- Serving capacity sized to peak is 60-80% idling at trough.
- Spot can cut training compute 50-70% when interruptions are survivable.
- Autoscaling yields faster response to new demand without perpetual over-provision.
- Checkpoint-plus-resume converts a scary eviction into a mild delay.
Mental model
A restaurant hiring dishwashers only for Saturday rush
Autoscaling
Keeping five dishwashers on payroll to cover a two-hour rush is idling money all week. Hire for ordinary load, call in burst help (scale-out) for Saturday, and let the shift manager stop the clock when traffic dies. Same is true for GPU capacity and a queue of jobs.
How it works
- Serving: autoscale on queue depth/latency with hysteresis — CPAs, min/max replicas.
- Training: scale queue worker pools; burst jobs onto spot during cheap windows.
- Spot: bid/preemptible pricing model, instance profile audited for tolerance.
- Checkpoint-and-resume: periodic snapshots (every N steps/minutes); resume from latest.
- Mix: reserve the critical floor, spot the burst headroom, on-demand the spot of last resort.
Autoscale + spot mix.
In production
- A serving mesh autoscales the model replicas on queue-depth with 30s hysteresis — peak and trough both cheap.
- A nightly retraining job bursts onto spot GPU with 10-minute checkpoints; a mid-run eviction costs 10 minutes, not a rerun.
- A batch experimentation queue prefers spot; the few jobs that matter hold a small reserved floor.
Best practices
- Autoscale on a lagging metric (queue depth) not just raw traffic.
- Apply hysteresis so scale-in/out doesn't flap on noise.
- Audit every workload's interrupt tolerance before allowing spot.
- Checkpoint frequency sized so eviction cost stays tiny and bounded.
Common mistakes
- Peak-ever-provisioned serving capacity, permanently.
- Spot for an interrupt-hostile workload, then surprise restarts every run.
- No checkpoints on spot jobs — eviction = full rerun, saving nothing.
- Autoscale flap from tight thresholds — buying and billing churn through scale-out/in.
Debugging tips
- Scale-out storm then sudden idle — thresholds too tight; add hysteresis and smoothing.
- Warm-up latency at scale-out — degree 0 replicas cold-start; pre-warm or buffer the surge.
- Spot evictions concentrated at peak hours — bid/index mat poor; schedule the tolerant jobs outside density windows.
Interview checkpoint
Hands-on lab
- Compare fixed-provision vs autoscaled serving cost
- Model spot discounts with eviction risk
- Show checkpoint-frequency bounds the loss
Elastic Cost Simulator
35 min · intermediate
Quick quiz
Hysteresis in autoscaling prevents…
Spot savings require engineering the checkpoint-and-resume path.