Free — no signup required

Monte Carlo Simulations for Cloud Spend

3 min read

What Is a Monte Carlo Simulation?

A Monte Carlo simulation is a technique for modeling systems with many uncertain variables by running thousands of randomized trials and observing the distribution of outcomes. The name comes from the Monte Carlo casino — the idea being that randomness, run at sufficient scale, reveals the underlying probability structure of a system.

You do not need a PhD to use one. The core idea is simple: instead of picking one value for each uncertain variable, you pick a random value from a realistic range, compute the result, and repeat thousands of times. The collection of results tells you what outcomes are likely, unlikely, and nearly impossible.

Applying Monte Carlo to Cloud Spend

Suppose you are forecasting costs for a SaaS platform. Your total monthly bill depends on several uncertain variables:

Variable Realistic Range
Monthly active user growth 5% – 15%
Average compute hours per user 2 – 6 hours
Spot Instance price (per hour) $0.10 – $0.50
Reserved Instance coverage 70% – 90%
Data egress per user (GB) 0.5 – 2.0 GB

A Monte Carlo simulation works as follows:

  1. Define variable distributions. For each variable, specify a probability distribution. A uniform distribution (equally likely anywhere in the range) is the simplest starting point. A normal distribution (most likely near the middle) is more realistic for many variables. A log-normal distribution works well for cost variables that can spike dramatically.

  2. Run trials. The simulation engine picks one random value for each variable, computes the total cost formula, and records the result. It repeats this 10,000 times (or more).

  3. Analyze the output distribution. The 10,000 results form a histogram. You read off percentiles: the 50th percentile (median expected cost), the 85th percentile (budget with moderate safety margin), and the 99th percentile (worst-case planning number).

The Power of Confidence Levels

Instead of telling your CFO "We need $1.2M," you say:

"Our simulation shows a 50% probability that costs land around $1.05M, an 85% probability that $1.2M covers us, and a 99% probability that $1.4M is sufficient. I recommend budgeting $1.2M and holding $200k in reserve."

This reframes the conversation from "give me a number" to "choose your risk tolerance." The CFO can now make an informed decision: accept the 15% chance of overrun, or pay the insurance premium of an extra $200k buffer.

In practice, most engineering organizations target the P85 or P90 as their budget number — enough safety margin to avoid mid-quarter surprises without over-allocating capital.

Choosing the Right Distribution

The choice of probability distribution for each input variable matters more than most practitioners realize:

  • Uniform distribution (flat probability across the range): Use when you genuinely have no idea where within the range the value will land. Good for new products with no history.
  • Normal (Gaussian) distribution (bell curve centered on a mean): Use for variables with a natural central tendency, like average session duration.
  • Log-normal distribution (right-skewed): Use for cost variables that have a floor but can spike dramatically upward — spot prices, data egress during viral events, or storage growth.
  • Triangular distribution (peak at the most likely value, tails at min/max): Use when you have a subject-matter expert estimate ("most likely 8 hours, but could be as low as 4 or as high as 20").

Using a uniform distribution for everything is a common beginner mistake. It overestimates the probability of extreme outcomes and underestimates the probability of outcomes near the center of the range.

Key Point: Monte Carlo simulations are only as good as their input distributions. Garbage-in, garbage-out applies here. The discipline is in honestly characterizing uncertainty — not in the math itself, which is straightforward. Senior engineers validate their distributions against historical data before trusting the output.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free