Skip to content
We areTOP 1%

What problems does sharding introduce, and how are they handled?

HardConceptDatabases: Replication & Sharding
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Sharding removes the single-node limit but gives up features that a single database provides for free. Expect follow-up questions on joins, transactions, hot spots and resharding.

  • Cross-shard queries and joins: denormalise data so common queries hit one shard, or aggregate results in the application (scatter-gather).
  • Distributed transactions: avoid them with a careful shard key; otherwise use two-phase commit, or sagas with compensating actions.
  • Hot spots: a celebrity account can overload one shard; split hot keys further, add a random suffix, or cache aggressively.
  • Resharding: moving data as the cluster grows is costly, so create many logical shards up front and map them to fewer physical nodes, or use consistent hashing.
  • Global secondary indexes and unique constraints need separate index tables or services.

More in Databases: Replication & Sharding

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account