Skip to content
StackDecode
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.

4911189728339475130859398885272411989603859464713934689N1: 10N2: 7N3: 6N4: 7
  • 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

  1. 1Query the directory with the key
  2. 2Get the shard
  3. 3Read or write there
  4. 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.

Related