SD System Design In Depth
0%
lesson system-designobject-storage

Range partitioning vs consistent hashing for storage

Module 2.3: Storage Engine Internals & Blob Systems Updated Sep 17, 2026
📄 Cheat Sheet
Introduction to Partitioning | Systems Design Interview 0 to 1 with Ex-Google SWE
Jordan has no life Introduction to Partitioning | Systems Design Interview 0 to 1 with Ex-Google SWE Watch on YouTube ↗

Jordan directly contrasts range-based and hash-based partitioning, their hotspot and range-query consequences, which is exactly this unit's comparison.

0:00 / --:--

The Fundamental Partitioning Dilemma

When a storage system grows beyond a single physical server, the keyspace must be split across hundreds or thousands of nodes. Distributed systems rely on two foundational partitioning paradigms: Range Partitioning and Consistent Hashing.

Architectural Comparison

flowchart TD subgraph RangePart ["Range Partitioning (Bigtable / Spanner / HBase)"] RNode1["Node 1: Keys a to g"] RNode2["Node 2: Keys g to p"] RNode3["Node 3: Keys p to z"] end subgraph HashPart ["Consistent Hashing (Dynamo / Cassandra / Riak)"] Ring["Token Ring [0 .. 2^64-1]"] HNode1["Node A (Token 1000)"] HNode2["Node B (Token 5000)"] HNode3["Node C (Token 9000)"] end

Tradeoff Matrix

DimensionRange PartitioningConsistent Hashing
Range QueriesExtremely Efficient: Sequential keys reside on contiguous nodes. BETWEEN '2026-01-01' AND '2026-01-31' hits exactly 1-2 nodes.Terrible: Adjacent keys hash to completely random positions on the ring. Range queries across partition keys require scatter-gather to every node (ranges within one partition key, via clustering or sort keys, stay efficient).
Hot Spot VulnerabilityHigh: Monotonically increasing keys (auto-increment IDs, timestamps) direct 100% of write traffic to the single tail partition.Spreads distinct sequential keys, but a single hot key or skewed request distribution can still overload one owner.
Metadata CoordinationRequires a centralized Partition Manager / Coordinator to track split boundaries and rebalance tablets.Decentralized: Nodes determine partition ownership locally via token ring ranges and gossip protocols.

Worked example: how much data moves when you add a node

A cluster has 10 nodes holding 10 TB. You add an 11th.

SchemeFraction of keys that moveData moved
hash(key) mod NAbout 10/11, roughly 91%About 9.1 TB
Consistent hashing with many virtual nodesAbout 1/11, roughly 9%About 0.9 TB, taken evenly from all nodes
Range partitioning with split and moveOnly the ranges assigned to the new nodeChosen by the balancer, for example about 0.9 TB

Worked example: the timestamp hotspot

An event table keyed by event_time under range partitioning receives 50,000 writes per second. Every new key is greater than all existing keys, so 100% of writes land on the tail range, whatever the cluster size. Fixes:

  • Composite key: (device_id, event_time) spreads writes across devices while keeping each device's events in time order.
  • Salting: prefix with hash(event_id) mod 16; writes spread over 16 ranges, but a time-range query must fan out to 16 ranges.
  • Pre-splitting: HBase and Bigtable users create split points ahead of time so a new table does not start on one server.

How real systems choose

SystemSchemeRange queries
Bigtable, HBase, Spanner, CockroachDB, TiKVRange, with automatic splitsEfficient across the whole keyspace
Cassandra, ScyllaDBHash of partition key on a token ringOnly within a partition, via clustering columns
DynamoDBHash of partition key into internal partitions, sort key ordered withinOnly within a partition key
MongoDBEither ranged or hashed shard keysDepends on the choice
Check yourself Question 1 of 3
Hot keys and hashing recall
From: Tradeoff Matrix

A single product key receives 40% of all reads. Does consistent hashing solve this hotspot?

Consistent Hashing Ring Visualizer
O(log N) Route

Observe how keys are distributed along a 360° circular hash ring. Add or remove nodes to see minimal key rebalancing in action!

Nodes: 4 | Virtual Nodes/Node: 3
0°
90°
180°
270°
Ring Size: 2^32
Clockwise Lookup
// Consistent Hashing Event Log
[INIT] Cluster established with Node_A, Node_B, Node_C, Node_D.
[READY] Binary search (upper_bound) active for ring lookups.

Key Takeaways

Range partitioning keeps data sorted, enabling ultra-fast range queries but risking severe write hotspots on sequential keys.
Consistent hashing uniformly distributes writes across nodes via hash tokens, but makes multi-key range scans prohibitively expensive.
Spanner and Bigtable choose Range Partitioning; Cassandra uses a consistent-hashing token ring, and DynamoDB hash-partitions the partition key into internally managed partitions (sort-key ordered within each).
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue