Three readers, three completely different bargains
A payments platform for a marketplace. Every money movement is a financial record, and three very different readers want at that data on terms that have nothing in common.
A card authorisation is being decided right now and cannot be told "not found" about something written a millisecond ago. A customer's history screen is read a thousand times for every write and does not care about the last few seconds. And the auditors want proof that no record is missing from any lookup path, down to a single entry.
One of these three is allowed to slow your writes down. Work out which.
- R1Every financial record written must be permanent and must never be edited in place. Corrections are new records, not changes to old ones.
- R2While a card authorisation is being decided, a record must be findable by a business key immediately after it is written. There must be no window in which a successful write reads back as missing — that window is a declined payment.
- R3The customer history screen queries by a different key, is read far more often than written, and tolerates a few seconds of lag. Building it must not add latency to writes and must not be able to stop writes happening, so nothing writes to it directly — it is derived from the records.
Outside every boundary: History screen (read constantly), Authorisation (deciding right now), Payments writer (one record per movement), Completeness check (records against indexes), Cold archive (past the window), an empty slot for the written once, corrected never, tier 1, an empty slot for the findable the instant it is written, tier 1, an empty slot for the derived, and a little behind, tier 2 Connections: Payments writer calls written once, corrected never written once, corrected never calls findable the instant it is written — on the write path Authorisation calls findable the instant it is written written once, corrected never publishes to derived, and a little behind — derived, off the path History screen calls derived, and a little behind written once, corrected never publishes to Cold archive written once, corrected never controls Completeness check