Debug Foundry

Servers come and go. Your keys shouldn't have to move.

Turn it, pause it, drag through the steps. Then try a different fleet change.

Not a video. A small simulation of consistent hashing: keys and servers on one ring, and only a slice moves when the fleet does.

Drag to turn · scroll or pinch to zoom

Finished state of the consistent hashing simulation: a ring on a warm tray with three server nodes and colored keys around it, each key owned by its next clockwise server

Three cache servers
share the keys

1/8First step sentence

    0.0s
    Replay the ending with

    What it's for

    Good to know

    The ring shown is the classic ring/successor scheme — one member of the consistent-hashing family, with rendezvous (HRW) and jump hash as siblings that share the goal with different mechanics. Hash the servers onto a logical circle (angle is not geography — a position, not a place), hash each key onto the same circle, and walk clockwise to the first server: here, ownership is the first node at an angle greater than or equal to the key's, wrapping past the end to the first node, and a key landing exactly on a node belongs to it — the toy's declared tie rule. The toy's hash is each key's declared position, so both schemes — ring and the mod-N baseline — map the same twenty keys, and every moved-key count shown is recomputed from that actual mapping, not assumed. When a server leaves, only the keys between it and its predecessor move — to its successor — and when one joins, it takes a slice from its successor. Everyone else's keys stay put, which is what "consistent" buys: minimal reshuffling, not zero. One honest flaw: three random server positions give three uneven slices, and an uneven ring is a hot shard by another name. The fix is virtual nodes — each server claims many small spots on the ring instead of one, so the law of large numbers evens the slices out; the toy shows the jump from 3 spots to 12. Spots, not machines: virtual nodes are extra positions for the same hardware, and they even out key counts, not popularity — a hot key still lands on one spot, the sharding chapter's celebrity in a new costume. The same idea travels far beyond caches: it's how Dynamo-style databases decide which node owns a row, tying this part's caching, sharding and replication chapters into one picture. It isn't free — you still need replication for durability (a ring alone loses the dead server's slice), lookups cost a hop of routing metadata, and weighted or bounded-load variants exist for fleets that aren't uniform. And the ring changes ownership on paper only: actually moving the bytes, teaching every client the new map and surviving the window where two maps disagree is a separate protocol — routing metadata, data transfer, concurrent traffic — which this toy deliberately omits.

    How it works, step by step

      Why the steps go in this order

      Before you rely on it

      This is a toy: twenty hand-placed keys, three servers, one ring. the moved-key counts (10 of 20, 7 of 20, 4 of 20, 16 of 20) are recomputed from the toy's declared mapping — about 1/N of the key space per change is an expectation under even-hash assumptions, not exact for twenty keys, and real distributions still skew. The ring says nothing about durability: when a cache server dies its slice is simply cold until refilled, and when a database node dies you need the replication chapter, not just the ring. The cited sources describe production systems with their own measured behavior.

      References