SteelReed

Search

Search posts, questions…

Data Modeling & ScalingQuestion 25 / 35

Middle

How does partitioning differ from sharding, and when are replicas not enough so you must shard?

Short answer

Partitioning splits a table on one server (pruning, cheap DROP PARTITION) but doesn't scale writes; sharding spreads data over many servers, scaling writes at the cost of global transactions, JOINs and uniqueness.

slow queriesread-heavyhuge time-based tablewrites exceed one boxWhere's the bottleneck?Fix query, indexCache, replicasPartitionShard

3 points to say:

  1. Partition: one machine, pruning, cheap drops; no write scaling. Shard: many machines, scales writes; loses global transactions and JOINs.
  2. Scaling order: queries, cache, replicas, partitions, fewer writes, only then shard; replicas only help reads.
  3. Hash is the default; time ranges easily pile writes onto one hot piece.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.