FDEBench Join us live

Q
135 / 159

Classification & routing

A sharded database routes by user_id modulo shard count. The team wants to add a shard. Explain what will happen and design something better.

question bank FDEBench bank

01
Ask

What a strong candidate asks first

Before designing anything. Skipping this is the most common way the round is lost.

  • How much data, and can we afford any downtime window at all?
  • Are there hot keys — a few users far larger than the rest?
  • Do queries ever span shards today?
  • Is this a one-time growth or will we be adding capacity continuously?

02
Rubric

What earns the points

7 criteria, 100 points total. Scored independently, partial credit allowed.

Shows nearly every key moves 20 pts

Shows that changing the divisor changes the target for nearly every key, so adding one shard implies moving almost all the data. Full credit requires the reason, not just "modulo doesn't scale".

If you miss it Say why modulo breaks. Changing N changes the mapping for essentially every key at once — the migration is the whole dataset, not the new shard's share.
Hash ring so few keys move 20 pts

Maps keys and nodes onto a ring with clockwise routing, and derives the property that matters: adding a node takes keys only from its successor, so movement is proportional to 1/N.

If you miss it You named consistent hashing without deriving its benefit. The point is that a new node intercepts only its neighbour's slice, so data movement drops from everything to roughly 1/N.
Spreads load with virtual nodes 15 pts

Adds virtual nodes so each physical node holds many ring positions, evening out distribution and spreading the load of a removal across many nodes.

If you miss it With one ring position per node, distribution is lumpy and removing a node dumps its entire range on a single neighbour. Virtual nodes fix both.
Compares fixed partitions 15 pts

Mentions the approach many production systems actually use — a large fixed number of logical partitions mapped to physical nodes, so rebalancing moves whole partitions and never rehashes — and compares it honestly to the ring.

If you miss it There is a simpler scheme worth naming: fix a large partition count up front and map partitions to nodes. Rebalancing then moves partitions with no rehashing at all, and it is easier to operate than a ring.
Handles one very busy user 12 pts

States that consistent hashing does not fix hot keys — one popular key still lands on one node — and proposes splitting, replicating, or caching it.

If you miss it Consistent hashing balances key *count*, not load. One enormous user still lands on one shard; that needs key splitting or a read replica for that key specifically.
Moves data under live traffic 10 pts

Specifies how the move happens under live traffic: dual-read or dual-write during the copy, verify, cut over, and a rollback path.

If you miss it You changed the routing scheme without saying how data moves while traffic is running. Dual-read during the copy, verify, then cut over — and say how you roll back.
Picks the shard key by queries 8 pts

Notes the hash key determines both distribution and which queries can be answered from one shard, so it is a query-pattern decision.

If you miss it You accepted user_id as the key without checking the query patterns. The shard key decides which queries stay single-shard — that is the part that is expensive to change later.

03
Flags

Red flags

Reported separately, not subtracted — this is the "what would have ended the interview" note.

  • Proposes a full-downtime migration for a live system with no alternative considered.
  • Never mentions virtual nodes or uneven distribution.
  • Assumes consistent hashing solves hot partitions.

—