Skip to content
About
Main content

Scenarios

Longer problems, like those in senior system design interviews. A strong answer estimates with numbers first, names the mechanism, then recommends a fix and says what it costs.

Try each one before you open the answer.
1An event table lives on object storage, and its request fees are 7 times its storage fees. Diagnose and fix.Show the answer

Estimate

Requests = files touched × queries. With 10 million files and 1,000 queries a day each touching 1%: 10⁸ GET requests a day, about $40 a day or $15,000 a year, against about $2,000 a year of storage.

Diagnose

Too many files touched per query: millions of 1–5 MB files. The fee scales with files × queries, not bytes, and it is a large share of cost even above the 100 KB . Parallel reads hid the , so no performance metric flagged it.

Fix

Compact to about 128 MB files, which cuts requests about 25-fold.

Trade-offs

is a permanent maintenance job, large files prune less finely, and need their own compaction and snapshot expiry. Measure files per partition monthly.

Read morePer-request pricingTarget file sizeLIST cost and manifests

2You want to cut the cost of a 6-hour nightly job on 100 nodes by 70% using spot instances, which are interrupted about 5% of the time per node per hour. Design it.Show the answer

Estimate

is 60–90% cheaper, but with 100 nodes at 5% per hour, the whole job survives an hour with probability 0.6%, and the first interruption comes after about 12 minutes.

Design

The coordinator and shuffle state on machines, workers on spot, and a every 5 minutes, so an interruption loses about 2.5 minutes of work on average rather than 3 hours. Expect about 40% of the on-demand cost: the includes the lost work.

Risks

Spot capacity disappears when total demand peaks, so keep an on-demand fallback. Handling interruptions costs engineering time, and the job must be able to recompute lost pieces from lineage.

Read moreSpot capacityRestart granularity decides the economics

3A development warehouse scales to zero, yet costs more than a small always-on one would. Analysts query it every 4–5 minutes. Why, and what do you do?Show the answer

Diagnose

If the idle timeout is shorter than the gap between queries, every query pays for a billed ; if longer, the warehouse never suspends. Sparse traffic is always cold and never idle.

Estimate

Elastic capacity wins only when the × the elastic premium is ; here the duty cycle is near 1 and the premium 3, giving 3. A 30-second cold start at $4 an hour costs about $0.033; a 10-minute idle tail, about $0.67.

Fix

Replace it with a small always-on warehouse, or set the timeout above the typical gap if the premium is lower.

Read moreScale-to-zero: a one-line break-evenCold start is a billing problemIdle warehouses

4A scheduled query was changed from daily to every 5 minutes, scanning 400 GB each run, and nobody noticed for 19 days. Prevent a repeat.Show the answer

Diagnose

A monthly feedback loop cannot catch changes that multiply cost within hours.

Inner loop

A dry-run cost estimate with a cap (for example 1 TB unless approved), a minimum schedule interval (say 1 hour), and same-day (alert at 3 times the 7-day average). Under those rules, 288 runs × 400 GB ≈ 115 TB a day is stopped on day one.

Outer loop

Tags (team, pipeline, environment), per-team warehouses (accepting the loss of sharing, since cannot be finer than isolation), and using two denominators that are biased in opposite directions.

Say also

What the cap's false positives cost, and that any alert still has some lag.

Read moreNobody sees the outcomeGovernors and runaway killsTagging and attributionUnit economics

5A colleague wants to sign a three-year commitment at a 45% discount, sized to last quarter's peak usage. Advise them.Show the answer

Sizing

An unused committed unit costs the committed price (0.6 of list); a missing one costs only the discount (0.4). Commit at the forecast percentile equal to the discount (the 40th for 40% off), not the peak; unused commitment is a flat line nobody notices.

Term

If list prices fall 20% a year, the , and almost all of it is in the first year. A one-year deal at a smaller discount may be better.

Meter

Check how bytes are counted, compressed or not, since that changes what compression is worth.

Also

Convertible commitments lower the cost of over-committing.

Read moreSizing from the shape of the lossA bet against price deflationWhich verdicts survive a price change

6Should you build a materialized view for a dashboard that runs about 1,000 queries a month?Show the answer

Formula

Example

Build $30, a daily refresh at $1 for 30 days, and storage $5, total $65; saving $0.50 per query gives N* = 130 queries a month, so 1,000 clears it easily. But if the table changes hourly with $10 refreshes, refreshes alone cost $7,200 a month, and it never breaks even. shrinks the refresh cost from the table's to the change's size, about 100× for 100 GB of changes on a 10 TB table.

Check the meter

On a cluster you already pay for, the marginal cost is near zero; under pricing per byte scanned, it is the full rate.

The unpriced term

The liability of keeping the view correct appears on no bill.

Read moreMaterialization break-evenThe unpriced termThe meter again

7A service in region A calls a database in region B 20 times for every page it renders. Evaluate the design.Show the answer

Estimate

per page, against about 20 ms within one region, plus charges per byte. Nothing at the call site shows that a region boundary is crossed.

Fix

Co-locate the service and the data, cache, or batch the calls; add a lint rule or a warning whenever a client's region differs from its database's.

General rule

Copying data wins when the total bytes of results over the planning horizon exceed the source's size; querying it remotely wins for rare, selective access, provided filters are pushed down to the source.

Read moreCross-region chattinessEgress and data gravity

8How would you estimate what a new pipeline will cost before it is built, and decide whether an optimization is worth doing?Show the answer

Estimate

Build a table: for each meter, the quantity, billing increment, minimum, expected and rate, including request counts that depend on file sizes. For example, 50 GB a day kept for a year is about 18 TB, about $420 a month at $0.023 per GB-month; writing it as 1 KB objects would mean .

Decide on optimizations

Price the labour: $4,000 of work saving $400 a month takes 10 months to pay back, before maintenance, so it is marginal; it is worth doing when spend is on a growth curve.

Rank the levers

Change the workload first, then the meter, then the layout, then the architecture.

Read morePricing a design before it existsLabour as a priced resourceThe escapes, ordered by price