Unit 14 of 14 · about 4 hours · measure
Skew, movement, abort and recovery measurement
A balanced key count can hide an overloaded shard, and a low abort rate can hide a broken isolation boundary. Measure costs together with invariant verdicts so an apparent improvement cannot come from silently dropping work.
You'll be able to
- Measure per-shard load, movement traffic and time, abort and compensation rates, duplicates and recovery time.
- Compare partition or workflow policies under matched workloads and fault schedules, with raw histories behind every table.
- Separate exact fixture counts, simulated time and local timing results, including runs that fail to recover.
Covers
Read
In this order, only the parts listed
0 of 2 done
- What to measure with which setupReplicated Log and Stream Processor - Partition and Workflow Slice
Milestone B - Instrumentation; Milestone E - Measurement / optimization; Measurement requirements; Reproducibility and Engineering judgment in the rubric
Apply the instrumentation and open-loop load guidance to partition movement and workflow recovery. Do not build the later stream-processing measurements yet.
- Reported figures are not targetsHLD Handbook - Sharding, Distributed Transactions and Idempotency
Virtual nodes: Practical numbers and Heterogeneous capacity; Bounded-load variant, opening hot-key paragraph; Real-World Example, Vimeo's bounded-load consistent hashing in HAProxy
Use these as hypotheses to test, not targets. Vnode counts and reported deviations do not guarantee request balance; the Vimeo figures describe its cache workload, not your database. Stop before Trade-offs.
Focus on
- Separate logical requests, attempts, aborts and successful unique effects. Give each rate a denominator; suppressed duplicate deliveries are not duplicate committed effects. Report invariant violations alongside throughput.
- Measure per-shard keys, bytes and requests separately. Count keys whose owner changes separately from bytes actually copied, including replica transfers, catch-up and retries; timestamp the cutover and record availability and tail latency during movement.
- For recovery, name the start event and the completion predicate. Fault healing, coordinator restart and invariant reconciliation are different clocks; a run still pending at the observation limit has no measured completion time.
- On your machine, compare a baseline and changed policy using the same workload and fault trace, then repeat across seeds. Record versions, offered load, concurrency, key sizes, durability settings, warmup, observation window, run count and spread; a seed alone cannot control OS scheduling.
Common mistakes · 3
- Reporting only latency of successful requests. Include errors, timeouts, pending work and achieved goodput at the stated offered load; otherwise overload can look faster.
- Treating observed key movement as a universal exact fraction. It depends on the key set, hash, placement and membership change; equal key counts need not mean equal bytes or request rates.
- Reporting zero aborts as a win without checking isolation, or excluding stuck recoveries from the summary. Both can reward a weaker or broken implementation.
Try it yourself
Closed-book, before checking anything
[0]*8 + [1]*2, routed by key % 2; keys 0 through 7 change owners from key % 3 to key % 4; a separate transaction history contains 12 completed attempts, three aborted and nine committed. Assert shard request counts [8, 2], maximum-to-mean request load 1.6, five changed owners and attempt abort fraction 0.25. If faults heal at simulated tick 20 and the first quiescent reconciled terminal state is tick 27, recovery is seven simulated ticks, not seven seconds. Then use the extractor on retained baseline and fault-run histories from loglab; label real durations as local measurements and preserve unresolved runs.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Does the fixture's five-of-eight movement result predict bytes copied?Answer
No. It counts owner changes for those keys and those modulo mappings. Byte cost also depends on record sizes, replica placement, catch-up and retransmission.
2.Three aborts in 12 completed attempts give what abort fraction, and do they prove three failed workflows?Answer
The attempt abort fraction is 0.25. They need not be three different workflows, and a retry may eventually commit. Report logical workflow outcomes separately.
3.Can the maximum alone decide whether a latency SLO passed?Answer
Only if the SLO is a maximum-latency bound. A percentile SLO needs that percentile over its defined request population and window, with errors and timeouts accounted for.
4.Faults heal, but reconciliation has not finished when observation ends. What recovery time should you report?Answer
Report recovery as incomplete at the observation limit, with elapsed time and pending state. Do not invent a completion time or omit the run. Simulated ticks remain separate from measured seconds.
You're done when
The extractor passes the fixed fixture, and a matched baseline/fault table reports skew, moved keys and bytes, abort and compensation denominators, duplicate effects, latency distributions, availability and completed or pending recovery. Keep three repetitions per setup and explain one cost or negative result without weakening the invariant.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 15 more in the section
- HLD Handbook - Sharding, Distributed Transactions and IdempotencyHLD Handbook · required
Read Part 2 database sharding, then Part 3 distributed transactions, idempotency and consistent hashing. Use Part 5 event patterns only for the chosen workflow design.
- Replicated Log and Stream Processor - Partition and Workflow SliceRoadmap-Final · support
Add partition routing, ownership epochs, rebalance, one cross-partition invariant and a durable transaction or saga path. Inject stale routes, coordinator death, duplicate steps and failed compensation.
Also in this section
- DDIA 2e - Chapters 7 and 8 Sharding and TransactionsMartin Kleppmann and Chris Riccomini · primary
Read both chapters completely. Build a decision table connecting access pattern, partition key, isolation, atomicity, failure and recovery before implementing either the partition map or workflow.
- A Critique of ANSI SQL Isolation Levels (Berenson et al., 1995)arXiv (Microsoft Research report) · required
Read the phenomena P0 to P3, the snapshot-isolation anomalies A5A (read skew) and A5B (write skew) and the summary tables. Cite these definitions, not the SQL-92 prose they correct.
- Weak Consistency: A Generalized Theory and Optimistic Implementations for Distributed Transactions (Adya, 1999)MIT LCS · support
Read the dependency-graph definitions of G0, G1 (a, b and c) and G2 and the levels PL-1 to PL-3 they define. They are the anomalies Elle checks on recorded histories.
- Serializable Snapshot Isolation in PostgreSQL (Ports and Grittner, 2012)arXiv · support
Read the dangerous-structure rule (two adjacent read-write antidependencies) from Cahill et al. and how PostgreSQL implements and limits it. False positives abort transactions, so measure abort rates.
- Sagas (Garcia-Molina and Salem, 1987)Cornell course copy · required
Read the whole paper: a saga is a sequence of transactions with compensating transactions, and compensation is application-defined. Name the steps whose effects cannot be compensated.
- Spanner: Google's Globally-Distributed Database (Corbett et al., 2012)Google (author copy) · support
Read TrueTime and the concurrency-control section (timestamps, commit wait, read-write and read-only transactions, two-phase commit over Paxos groups). TrueTime needs clock hardware, so emulate bounded uncertainty in simulation.
- Large-scale Incremental Processing Using Distributed Transactions and Notifications (Peng and Dabek, 2010)USENIX OSDI · support
Read the snapshot-isolation transaction protocol over Bigtable (primary lock, timestamp oracle) and notifications. Snapshot isolation still admits write skew.
- CMU 15-445 - Concurrency Control, Logging and RecoveryCarnegie Mellon Database Group · required
Follow Fall 2025 lectures 17 to 22, the transactions homework and the concurrency-control project where available. Reproduce lost update and write skew outside the project before claiming an isolation level.
- PostgreSQL 18 Documentation - Transaction Isolation and Explicit LockingPostgreSQL Global Development Group · required
Read Section 13.2 (Read Committed, Repeatable Read and Serializable with its serialization failures) and 13.3 (row locks and deadlocks). Reproduce write skew under Repeatable Read and its rejection under Serializable in the
postgres:18image. - The Internals of PostgreSQL - Concurrency ControlHironobu Suzuki · support
Read Chapter 5 Sections 5.5 to 5.9 (snapshots, visibility rules, preventing lost updates and serializable snapshot isolation) to see one real engine implement the anomalies and isolation levels you reproduce. Note the date you read it.
- MIT 6.5840 - Distributed Transactions and Lab 5 Sharded KVMIT PDOS · required
Use lecture 11 and Lab 5 for coordinator failure, shard ownership and migration. Treat the lab as the integrated advanced path; a smaller deterministic partition map is sufficient for the compulsory gate if time is constrained.
- DSLabs - Lab 4 Sharded Store and TransactionsUniversity of Washington (Ellis Michael) · support
Labs are Java 21 message-passing state machines tested on an emulated network and by model-checking search tests that print a minimal violating trace; run them with the
run-tests.pyscript and its--laband--partoptions. Lab 4 adds a shard master, shard movement and multi-key transactions across groups with two-phase commit and locking (Part 3): use it for the commit protocol across groups, which MIT Lab 5 does not exercise. - Gossip Glomers - Totally Available TransactionsFly.io and Jepsen · support
Each challenge runs locally under Maelstrom (v0.2.4; the pages were tested on 0.2.3) with its checker and, where the page says so, the partition nemesis; keep the run directory as the history. Do 6a to 6c (read-uncommitted, then read-committed transactions under partition). The 6b page says the checker cannot detect G0 anomalies, so a pass is weaker than its label.
- Building Distributed Systems - The Sharder and The CoordinatorBuild Distributed Systems · optional
Only the first three tasks of each track are free: in The Sharder, a shard controller, consistent hashing and configuration change; in The Coordinator, two-phase commit, coordinator failure and three-phase commit. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- AlgoMaster System Design - Selected Sharding and Transaction ProblemsAlgoMaster · support
Use the sharding, consistent hashing, ACID, saga, idempotency and outbox lessons as vocabulary, and the problems Calculate Hash Shard Load, Count Keys Moved by Resharding, Merge Cross-Shard Top-K Results, Analyze Transaction Serializability, Build a Saga Compensation Order and Consume Outbox Events Idempotently and in Order as drills. The capstone must supply real persistence, fault history and load evidence.