PRO

Effect Consistent Hash Ring

Ring placement that survives membership churn: keys and nodes hash onto the same 2^32 circle (FNV-1a with an avalanche finisher), a key belongs to the first node clockwise, and each node appears as many virtual nodes so the arcs stay statistically even. Adding a node moves roughly 1/N of the keys (all onto the new node, none between old ones) where hash(key) % N would move nearly all of them, and removing a node reassigns only the leaver's keys. The ring is an immutable sorted array swapped atomically in one Ref, so a lookup never observes a half-applied membership change, and lookup is a binary search. Solves the full reshuffle on scale-out and the lumpy ring hotspot. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-consistent-hash-ring.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
placement
keys remapped
0
cache-5 joins
readonly string[]
serverIndex = hash(key) % N // N changed, so everything changed

cache-5 joins and N changes from 4 to 5, so hash(key) % N changes for almost every key: 8020 of 10000 keys now point somewhere new, and each one is a cache miss. The cluster stampedes its own origin at the exact moment it was scaling to protect it.

Files

Dependencies