コンシステント・ハッシングは、ノード(サーバ)が追加または削除されるときの再分配を最小化するデータ分散技術です。単純なハッシングと異なり、ノード数が変わってもほとんどのキーを再マッピングしません。分散キャッシュ、データベース、負荷分散に重要です。
単純なハッシングの問題
Simple approach: node = hash(key) % N (N = number of nodes)
✗ when N CHANGES (add/remove a node), N changes → MOST keys remap to different nodes →
massive data movement / cache invalidation (almost everything moves!)
→ adding/removing a server causes huge disruption → bad for dynamic distributed systems.
コンシステント・ハッシングの仕組み
Map both NODES and KEYS onto a HASH RING (a circle of hash values):
→ a key belongs to the FIRST node clockwise from it on the ring
→ adding/removing a node only affects keys in ONE segment of the ring (its neighbors) →
only a SMALL fraction of keys move (≈ K/N, not most of them)
→ minimal redistribution when nodes change → much better for dynamic systems.
