Cloud, SaaS & IT Spend Cloud Infrastructure Cost Exponential interruption model (memoryless hazard)

Spot Instance Savings and Interruption Calculator

A 70% spot discount is not a 70% saving if the job restarts twice. This calculator prices spot capacity the way it actually behaves: interruptions arriving at a constant hazard rate, work lost back to the last checkpoint, and the whole attempt repeated when there is no checkpoint. You get the expected compute hours per completed job, the expected number of interruptions, the true cost each way, and the job length beyond which the lost work overtakes the discount. Change the checkpoint interval and the table shows exactly what that buys.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
On-demand hourly rateList price for the same instance type you would use if spot were unavailable.0.384 $/h
Spot hourly rateCurrent spot price for that instance type in the availability zone you will run in.0.115 $/h
Cost per restartFixed cost of recovering from one interruption: image pull, warm-up, orchestration, data re-staging.0.5 $
Work in one jobUninterrupted compute the job needs, excluding any checkpoint overhead.24 h
Interruption probability per hourChance the instance is reclaimed in any given hour. Provider interruption dashboards publish this by instance type and region.3 %
Checkpoint intervalHow often the job saves recoverable state. Enter 0 if an interruption means starting the job again.0 h
Checkpoint overheadExtra runtime that writing checkpoints adds. It is applied only when a checkpoint interval is set.5 %

It returns

  • Expected spot cost per completed job — Compute actually consumed, including repeated work, plus restart costs.
  • On-demand cost per completed job
  • Saving per completed job — Negative means spot costs more once interruptions are priced.
  • Saving as a share of on-demand
  • Expected compute consumed — Billed hours per completed job, including work repeated after an interruption.
  • Expected interruptions per job
  • Expected attempts per segment — With no checkpointing the segment is the whole job, so this is attempts per completion.
  • Job length where spot stops paying — Blank when spot remains cheaper at every length up to 2,000 hours.

The formula

E[H]=keλc1λ
C=rspotE[H]+rrestartk(eλc1)

In plain text: E[hours] = k · (e^(λc) − 1)/λ, λ = −ln(1 − p), k = work / c

  • E[H]Expected compute hours billed per completed job (h)
  • λInterruption hazard rate, derived from the hourly probability p (per hour)
  • pProbability the instance is reclaimed within any one hour (decimal)
  • cCheckpoint interval — the length of one recoverable segment (h)
  • kNumber of segments: work (including checkpoint overhead) divided by c (count)

Interruptions are modelled as a Poisson process, so the time to interruption is exponential and memoryless. Each segment is retried until it completes; expected attempts per segment is e^(λc), and expected interruptions is k(e^(λc) − 1).

Updated Category Cloud Infrastructure Cost Verified against published test cases Reading time 10 min

Why the spot discount is not the spot saving

Spot capacity is spare provider inventory sold at a deep discount on the condition that it can be taken back with about two minutes' notice. The discount is real and large. What the rate card cannot tell you is how much of the work you paid for survives, and that is what decides whether spot is cheaper for your particular job.

The mechanism is simple and unforgiving. If an interruption arrives partway through an unprotected job, everything computed since the start is discarded and the job begins again. You paid for those hours. So the effective price per completed job is the spot rate multiplied not by the job length but by the expected compute consumed, which is always larger and grows faster than linearly with job length.

Checkpointing changes the shape of the problem completely. If the job saves recoverable state every hour, an interruption costs at most an hour of repeated work regardless of how long the whole job runs. That converts an exponential relationship between job length and cost into a linear one, which is why long jobs on spot are a checkpointing question rather than a pricing question.

This calculator therefore prices three things together: the discounted rate, the compute repeated after interruptions, and the fixed cost of each restart. The last one matters more than people expect on short segments, because a job checkpointing every fifteen minutes restarts often, and each restart pays for image pulls and warm-up whether or not much compute was lost.

A memoryless hazard, and the expected-hours formula

Model interruptions as a Poisson process: the chance of reclamation in the next instant does not depend on how long you have already been running. If p is the probability of interruption within one hour, the equivalent hazard rate is λ = −ln(1 − p) per hour. At 10% an hour that is 0.105361, slightly above 0.10, because the hazard compounds continuously.

For one segment of length c that must complete without interruption, the probability of success is e^(−λc), so the expected number of attempts is e^(λc). Each failed attempt consumes only the time until it was interrupted, and the expected time consumed per attempt is (1 − e^(−λc))/λ. Multiplying attempts by time consumed — which is valid because the attempts are independent and the count is a stopping time — gives the compact result

E[hours per segment] = (e^(λc) − 1) / λ.

Check the limits. As λ approaches zero the expression approaches c, which is the no-interruption case. As λc grows the expression blows up exponentially, which is the long unprotected job that never finishes. Expected interruptions follow directly as k(e^(λc) − 1) for k segments.

The consequence worth internalising is that with a fixed checkpoint interval, job length stops mattering. Cost is k segments each costing the same, and k is proportional to job length, so cost per hour of work is constant. Without checkpointing, c equals the whole job and cost climbs exponentially with length. That is why this calculator reports a crossover job length only when the exponential regime can actually reach the on-demand line.

Worked example: a 24-hour job at 3% interruption an hour

A training job needs 24 hours of compute. On-demand is $0.384 an hour, spot is $0.115, the instance type shows roughly a 3% chance of reclamation per hour, restarting costs $0.50, and the job has no checkpointing.

  1. Hazard rate. λ = −ln(1 − 0.03) = −ln(0.97) = 0.0304592 per hour.
  2. Segment length. With no checkpointing the segment is the whole job: c = 24 h.
  3. Expected attempts. e^(0.0304592 × 24) = e^0.731021 = 2.0772. On average the job runs to completion on the second or third try.
  4. Expected compute. (2.0772 − 1) ÷ 0.0304592 = 1.0772 ÷ 0.0304592 = 35.37 hours billed for 24 hours of useful work.
  5. Expected interruptions. 2.0772 − 1 = 1.077.
  6. Spot cost. $0.115 × 35.37 + $0.50 × 1.077 = $4.067 + $0.539 = $4.61.
  7. On-demand cost. $0.384 × 24 = $9.22.
  8. Saving. $9.22 − $4.61 = $4.61, almost exactly half, against a headline discount of 70%.

Now add hourly checkpoints with a 5% overhead. The work becomes 25.2 hours in 25.2 segments of one hour; each segment costs (e^0.0304592 − 1) ÷ 0.0304592 = 1.015385 hours, so expected compute is 25.58 hours — down from 35.37 — with 0.78 expected interruptions. Spot cost falls to $0.115 × 25.58 + $0.50 × 0.78 = $2.94 + $0.39 = $3.33. Checkpointing bought back $1.27 on a single job, and it is the difference between a 50% and a 64% realised saving.

How to read the result

Look at expected compute against actual work first. A ratio near 1.0 means interruptions are a rounding error and you should be on spot. A ratio above roughly 1.5 means you are paying for a large amount of repeated work, and the fix is checkpointing rather than a different instance type. Above 2.0 the job may be effectively unable to finish during busy periods, whatever the arithmetic says about expectations.

Then read the crossover job length. If it is blank, spot remains cheaper at every length the model covers, which is the normal result once checkpointing is in place. If it is finite and close to your job length, the decision is fragile: interruption rates vary by zone, by instance type and by time of day, and a rate twice what you entered halves the crossover.

Treat the expected number of interruptions as an operational figure, not just a financial one. Each interruption is a scheduling event, a possible partial write, and a log entry someone will read. A pipeline expecting 0.1 interruptions per job needs no special handling; one expecting 3 needs idempotent steps, safe resumption and monitoring that does not page a human.

Finally, remember what spot does not fit. Anything with a hard deadline, anything holding unreplicated state, and anything that cannot tolerate a two-minute termination notice belongs on committed or on-demand capacity. The right portfolio is usually committed capacity for the steady floor, spot for the elastic and interruptible layer, and on-demand for the gap.

Expected compute per hour of work at different interruption rates

Expected billed hours per one hour of useful work, computed as (e^(λc) − 1) / (λ·c) with λ = −ln(1 − p) and c the checkpoint interval. Checkpoint overhead is excluded so the columns show the interruption effect alone.
Interruption rate per hourc = 0.5 hc = 1 hc = 4 hc = 12 hc = 24 h
0.5%1.00131.00251.01011.03071.0626
1%1.00251.00501.02041.06281.1309
3%1.00771.01541.06351.20721.4736
5%1.01291.02611.11001.38201.9697
10%1.02681.05461.24372.00954.5624
20%1.05791.12041.61495.061039.3540

Multiply your job's hours of work by the figure in the cell to get expected billed hours. The column for c = 24 h with no checkpointing is where long unprotected jobs become unaffordable; the c = 1 h column shows how completely checkpointing removes the problem.

Where the interruption rate comes from

Do not guess this input. AWS publishes a Spot placement score and an interruption-frequency view by instance type and region; Google publishes preemption behaviour for Spot VMs, which are always reclaimed within 24 hours; Azure publishes eviction rates for Spot Virtual Machines. All three vary by capacity pool, so the same instance family can be quiet in one zone and turbulent in the next. Convert whatever your provider publishes into a per-hour probability before entering it — a rate quoted per month is not the same number, and using it directly understates the hourly hazard by a large factor.

Assumptions this model makes

  • Interruptions are memoryless. Real reclamation clusters when a capacity pool tightens, so a bad hour is more likely to be followed by another bad hour than this model assumes. Treat the result as a floor on expected cost.
  • The spot price is constant. Spot rates float and are capped at on-demand. If your workload runs for weeks, sample the rate over a period rather than taking today's.
  • Capacity is available when you retry. During a genuine shortage the retry does not start immediately, and the delay is a schedule cost this model does not price.
  • Checkpoint overhead is a flat percentage. In practice it depends on state size and storage throughput, and writing a checkpoint to remote storage also costs requests and transfer.
  • One instance is modelled. A distributed job across many spot instances is interrupted far more often than a single one, because any node being reclaimed can stall the whole job.
  • No fallback is priced. Most production users run spot with an on-demand fallback, which raises cost and removes the tail risk of a job never finishing.

Making spot work in practice

The single highest-value change is checkpointing, and the table above shows why: at a 10% hourly interruption rate, hourly checkpoints cut expected compute for a 24-hour job from 4.56 times the work to 1.05 times. Nothing about the price negotiation comes close to that. Choose the interval by balancing lost work against restart cost and overhead — the calculator's own table sweeps it for your inputs.

Diversification is the second lever. Spreading a job across several instance types and availability zones draws on independent capacity pools, and provider schedulers will place into the deepest pool available. Fleet-style APIs exist precisely for this and typically reduce effective interruption rates well below any single pool's figure.

Third, match the workload to the mechanism. Batch analytics, CI runners, media transcoding, rendering and model training with checkpointing are all natural fits. Stateful databases, single-instance queues and anything user-facing are not. For the workloads that do not fit, the alternative is a commitment on the steady floor, and where the runtime itself is negotiable the serverless comparison is worth running before either. Whatever mix you land on, divide the result through the unit cost calculator so the saving is visible in a number the business tracks.

Frequently asked questions

How much do spot instances actually save?

The discount off on-demand is typically large, but the realised saving is smaller because interrupted work is repeated and each restart has a cost. In the worked example above, a 70% headline discount produced a 50% saving without checkpointing and 64% with hourly checkpoints. Run your own interruption rate and job length; the gap between the discount and the saving is the whole point of this calculator.

What interruption rate should I enter?

Use your provider's published figure for the exact instance type, region and zone, converted to a per-hour probability. All three major providers publish interruption or eviction frequency data, and the rates differ by an order of magnitude between capacity pools. If you only have a monthly figure, convert it rather than entering it directly, because an hourly hazard and a monthly frequency are very different numbers.

How often should I checkpoint?

Short enough that expected lost work is small, long enough that overhead and restart costs do not dominate. The table in this calculator sweeps the interval for your own inputs and shows total cost at each, which is the direct answer. As a starting point, an interval where expected compute is under about 1.1 times the work usually leaves little to gain from going shorter.

Can a job on spot fail to finish at all?

Yes, in the sense that an unprotected job longer than roughly the mean time to interruption may keep restarting indefinitely during a capacity shortage. The expected-attempts figure makes this visible: once it climbs above about three, you are relying on luck. Checkpointing removes the failure mode entirely, because progress is preserved across attempts.

Does the two-minute termination notice help?

It helps if you use it. Two minutes is enough to write a checkpoint, drain a queue consumer, or deregister from a load balancer, and handling the notice properly turns many interruptions into clean handovers rather than lost work. It is not enough to complete a long computation, so it complements checkpointing rather than replacing it.

Is spot cheaper than a reserved instance?

Per hour, usually yes; in role, they are not alternatives. A commitment suits steady capacity you will run whatever happens, and it cannot be reclaimed. Spot suits elastic, interruptible capacity above that floor. Most cost-efficient fleets use both: a commitment sized to the baseline and spot for the variable layer.

How do interruptions behave across a distributed job?

Badly, unless the framework tolerates node loss. If any one node being reclaimed stalls the whole job, the effective interruption rate is roughly the per-node rate multiplied by the node count, so a 32-node job on 3%-per-hour instances faces a very different hazard from a single instance. Model the cluster hazard rather than the instance hazard, and prefer frameworks with elastic membership.

Why is the hazard rate not just the hourly probability?

Because probability compounds over continuous time. A 10% chance per hour corresponds to a hazard of −ln(0.9) = 0.105361 per hour, slightly higher than 0.10, and the difference grows with the rate: at 50% per hour the hazard is 0.693. Using the raw probability as a rate understates interruptions, and the error is largest exactly where it matters most.

References