BuildSeniorBackendAuto-graded
Stop a hash ring from reshuffling every key
When a node joins or leaves, almost every key moves to a different server. Make only a small share move.HashRing(nodes, vnodes=...) in ring.py should map keys to nodes so that adding or removing a node moves only about 1/N of the keys. In production every membership change sends nearly the whole cache cold, and two service instances sometimes disagree on who owns a key. Rebuild it as a ring with vnodes points per node: a key goes to the first point clockwise from its position, and the ring wraps around. Use the provided _stable_hash for every position.45 min
python
You're done when
- Separate processes built with the same nodes map every key to the same node.
- Removing a node moves only the keys that were on it. Every other key keeps its node.
What it measures
Data structures and algorithmsHow the ring and its virtual points are built, and whether a membership change only touches the node that changed.
Distributed systemsWhether you understand what lets a key-to-node mapping survive a cluster resize.
Cross-process determinismWhether the ring gives the same answer in every process and on every machine.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
45 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo