open atlas
↑ Back to track
System Design Case Studies SDC · 05 · 07

Data & money: multiple-choice review

Multiple-choice synthesis across the data-and-money cases: cardinality, exactly-once and watermarks, idempotency and the double-entry ledger, the lost update, exchange determinism, and the double-booking race.

SDC Senior ◷ 13 min
Level
FoundationsJuniorMiddleSenior

Six questions that cut across the unit. Each is a decision you make in a design review where the output is money or correctness-critical data — not a definition to recite, but the reasoning that prevents a double-charge, a cardinality OOM, or a double-booking.

Confirm you can spot the cardinality bomb, separate exactly-once from late events, apply an idempotency key, defeat a lost update, justify a single-threaded exchange core, and prevent a double-booking.

Quiz

A metrics team adds a label `user_id` (millions of values) to a high-traffic metric. What breaks, and why?

Quiz

In ad-click aggregation, a click arrives 30 minutes late; its event-time window closed long ago. Exactly-once is enabled. Is it counted, and how do you still bill it?

Quiz

A client charges a card, the PSP succeeds, but the response is lost; the client retries. What prevents the double charge, and where must the key originate?

Quiz

Two concurrent debits ($70, $60) both read a $100 wallet balance, both pass their check, both write back, and the wallet overdraws. What is this and the cleanest single-wallet fix?

Quiz

An exchange's matching core is single-threaded over a sequenced stream. An engineer proposes multiple matching threads 'to go faster.' Why is that wrong?

Quiz

Two guests book the last room for the same night within a second; both saw '1 available' and both got confirmations. What is this, and the correct fix for a multi-night stay?

Recall before you leave
  1. 01
    Why is exactly-once not the answer to a late event?
  2. 02
    What's the common thread between the lost update and the double-booking?
Recap

The unit’s hazards are a named checklist you run in any design review where the output is money or correctness-critical data. The cardinality bomb: series count is the product of label cardinalities, so an unbounded label OOMs the TSDB — keep labels bounded. Exactly-once vs lateness: exactly-once stops double-applying, not late events, which a watermark sizes for and batch reconciliation recovers. The idempotency key: client-minted, atomic check-and-store, so a retry after a lost response returns the original result instead of charging twice. The lost update and the double-booking are the same read-modify-write race — fixed by making check-and-act one atomic operation (per balance, or per night all-or-nothing). And exchange determinism: a single sequenced total order through a single-threaded core, so replicas and replay agree — never parallelize one book. Each hazard has a precise, atomic fix, and recognizing which one you’re facing is the senior skill this unit builds.

Connected lessons

Something unclear?

Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.

shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.