Course contents
On this page
Lesson plan 29: Partitioning and routing
Choose partition keys and routing metadata from access patterns, tenant boundaries, and skew.
Placement: Part 5: Correctness across machines.
Prerequisites: Lesson 28: Consensus and leadership, plus the earlier dependency chain.
Learning outcomes
- Choose partition keys and routing metadata from access patterns, tenant boundaries, and skew.
- Trace ownership transfer during splitting or rebalancing without admitting two authoritative owners.
- Explain why a hot logical key survives naive resharding.
- Separate a general mechanism, a documented implementation choice, and an illustrative numerical assumption.
Teaching sequence
- Establish the motivating situation: An ordered timestamp key sends all new writes to one range even after adding nodes.
- Introduce the vocabulary and the correctness obligation before an optimization. Define hash partitions, ranges, metadata.
- Develop the mechanism: Follow a split or move with authoritative routing versions and concurrent writes.
- Follow the complete worked example: 100000 writes/s across 100 shards averages 1000 each, but a 40% hot shard receives 40000. Explain the assumptions, intermediate units, and limiting interpretation.
- Extend the scenario to changed load, skew, or failure, explaining placement, hotspots, rebalancing, resharding, tenant boundaries.
- Connect the mechanism to a documented implementation and an alternative with a different workload fit. Close by stating the remaining cost and the next lesson dependency.
Required chapter material
Use a complete execution trace or worked calculation, supported by an annotated static diagram or table. Include language-neutral pseudocode or labeled SQL when it clarifies the mechanism. State preconditions, ownership, visibility, and failure boundaries for algorithms. Describe operational costs as well as the normal path. All questions raised in the narrative must be resolved in the text.
Visual explanation
A key-to-shard map and migration timeline mark the ownership epoch, copy phase, catch-up, cutover, and stale-router response. The accompanying prose explains the arrows, state changes, or table entries so the lesson remains understandable in a plain Markdown reader.
Editorial checks
Confirm that the numerical example agrees with its units and assumptions. Check that a faster path preserves the stated contract, or explicitly identify the changed guarantee. Keep hypothetical figures separate from product measurements. Explain both an appropriate use and a limitation of the case design. Check terminology against the glossary and links against the course index.