System Design
5. Advanced Database ArchitectureAnimated
Directory-Based Sharding
A lookup table maps keys to shards.
The idea
A directory service says which shard owns each key, giving full flexibility to move data.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- outlined = moved key
Directory-based: a lookup table says which shard owns each key. Flexible and easy to rebalance, but the directory is a new component that must be fast and highly available.
- nodes:
- 4
- moved:
- 0
1/2
Each square is a key; its colour is the shard that stores it.
Step by step
- 1Query the directory with the key
- 2Get the shard
- 3Read or write there
- 4Update the directory to move data
Where it is used
Custom placement and tenant isolation.
Watch out for
The directory is a new bottleneck and SPOF.