Cost Mechanics
What is metered, and what is the smallest increment you are charged for?
Who this mechanism is for: a developer who writes code, calls cloud APIs and knows basic SQL, but has never studied how cloud vendors price storage, compute and network, or why a bill can be several times larger than a forecast made from the price list. You do not need any database or finance knowledge. Every technical term is explained the first time it appears, and again in the glossary at the end.
The story we will follow
Tomás is a data engineer at Brightloom, a small company that sells an analytics product to retail shops. Brightloom collects sales events from thousands of shops, stores them as files in cloud object storage (a service that keeps files, called objects, behind an HTTP interface), and answers dashboard questions with a query engine that reads those files. A manager, Priya, owns the budget. She forecast $12,000 of cloud spend for the first full month of production. Every number in her forecast came straight from the vendor's price list.
The invoice arrives on day 31. It says $41,000. Nothing crashed, no alarm fired, and every rate on the invoice matches the price list.
During this mechanism Tomás will meet five problems, one at the start of each of the first five parts. Each problem looks like a bug. Each one is actually a consequence of how a price is built: what is metered, in what increments, and who sees the number. At the end of each article, we go back and solve his problem. What lasts asks what survives when the vendor changes the price list.
The main idea of this mechanism:
How this mechanism is organized
- 1
Pricing primitives
What can a vendor meter, and why do rates matter less than metering rules, minimums and utilization?
CaseA $41,000 invoice against a $12,000 forecast
- 2
Design consequences
Which designs exist because of the price list and not because of performance?
CaseRequest fees at seven times storage
- 3
Elasticity
Who holds the risk when your demand is uncertain, and what do they charge?
CaseA spot job that never finishes
- 4
Control and attribution
Why does cost have no alarm, and how do you build one?
CaseA 5-minute schedule, found 19 days later
- 5
Anti-patterns
Why do reasonable designs produce unreasonable bills?
CaseFive sensible choices, five leaks
- 6
What lasts
Which conclusions survive a price change, and which flip?
CaseA new price list: which fixes stay right?
After that: a summary, hands-on labs, interview questions and a glossary.
One request: do not skip the arithmetic. Prices change every year. The shape of each calculation (a ratio, a break-even, an exponent) is the content you will reuse.
What do I do, and what does each option cost?
Can I see it myself?
Price a workload from the metering definition, not the rate
Bill one workload three ways — quantity × rate, with a minimum increment, and batched — then compare effective prices.
SimulatePythonFind the small-file crossover on your own bucket
Read 1,000 small objects and one large one from an S3-compatible store: concurrency changes the time, never the request count.
Real systemDocker, PythonMeasure the top-1% share of your query log
How much of a warehouse bill the most expensive 1% of queries carry, for cost distributions of different tail weights.
SimulatePython with NumPySimulate the spot gang
A job that needs 100 spot nodes at once: its hourly survival, and how checkpointing sets its completion time.
SimulatePython with NumPyTest the commitment-sizing rule
Find the commitment level that minimises a year of cost under skewed demand, and how a falling price moves it.
SimulatePython with NumPyDry-run before you run
Estimate a query's scanned bytes from Parquet metadata four ways: every column, two columns, a partition filter, an uncorrelated filter.
MeasurePython with PyArrow
Can I reason about it under questioning?
Interview questions
Short questions on what cloud data systems cost, such as pricing meters, file sizes and compression, elasticity, spot and commitments, and cost control, each with an answer you could give aloud and a link to the full explanation.
Scenarios
Longer problems on the cost of cloud data systems, of the kind asked in senior interviews: each one estimated with numbers, diagnosed, and answered with its trade-offs.
The tensions this mechanism takes a position on. Each recurs across mechanisms.
Cost as a substitutable resource
Money buys position on every other axis; the only axis denominated in a different unit.
Isolation vs. utilization
For example: multi-tenancy, resource pools, spot capacity.
Precompute vs. compute-on-read
For example: materialized views, ELT vs. ETL, schema-on-read.
Space vs. time
For example: compression, indexing, materialization, caching.
Coupling vs. coordination cost
For example: 2PC vs. sagas, schema contracts vs. schema-on-read.
Ideas this mechanism meets that keep coming back, mechanism after mechanism.
Variance costs more than volume
Variance costs more than volume.
Granularity mismatch
Granularity mismatch creates amplification.
Fixed cost per operation
Fixed cost per operation implies a natural batch size.
Opacity forfeits optimization
Opacity forfeits optimization.
Independence is assumed
Independence is assumed everywhere and is true almost nowhere.
Show all 12 principlesShow fewer
Sound approximations
When exactness is too expensive, use a sound approximation.
Costs are conserved
Costs are conserved, never removed.
Immutable storage grows indirection
An immutable substrate grows an indirection layer plus a collector.
Absence is not evidence
Absence of an event is not absence of a failure.
Hidden state breaks replay
A replayable pipeline is a pure function of its retained inputs.
Fixed capacity meets growth
A fixed-capacity structure meeting growing cardinality breaks the design.
Retention is paid by the live path