Agree on the balance
Ledger keeps a group’s shared expenses, and before a settle-up every member checks what they owe.
15 minMediumMembers kata
Membership isn’t open yet. One kata or case is open to you now, 1 more with a free account.
The brief
Ledger keeps a group’s shared expenses, and before a settle-up every member checks what they owe. The balances table runs as a group of 3 copies: a write is confirmed once W copies have it, a read asks R copies and keeps the newest answer, and a copy a write didn’t wait for trails about 1 s behind. Today W = R = 1. The evening sends 600 group pages, 30 new expenses and 20 balance checks a second for 52 seconds, from about 300 active members (the run lasts 60 seconds, so the last requests finish). At second 20 one copy fails; from second 40 to 42 a second one is down too; both come back at second 50. In this sim a copy that’s down stands in for one cut off by a network split, a write or read that can’t reach its W or R live copies is refused, and each extra copy waited for adds 10% to that request’s database time. Keep at least 93% served, P99 under 40 ms, and make sure no member ever reads a balance missing an expense they added. The copies, their lag and the pool are the database team’s, and so is the router: you choose W and R.
What it checks
- 1Predict whether a read can miss the latest confirmed write from N, W and R, and how many copies can be down before writes or reads fail.
- 2Choose W and R for a Ledger table from its read / write mix and how much staleness and downtime it tolerates — fast reads, fast writes or balanced.