System Design

Scaling Databases with Consistent Hashing

System Design diagram · made in Skemio

Architecture diagram illustrating consistent hashing ring routing requests from an API gateway to virtual nodes and physical database shards.
Architecture diagram illustrating consistent hashing ring routing requests from an API gateway to virtual nodes and physical database shards.

What it shows

  • Modulo hashing forces massive rebalancing; ring hashing moves only K/N keys.
  • Virtual nodes prevent hot spots by scattering shards across the hash space.
  • Clients locate partitions locally in O(log N) using a binary search ring.

The takeaway

Consistent hashing keeps sharded clusters stable by localizing data movement during rebalances.

More system design diagrams