Firefly Hash Ring
Hundreds of fireflies need a home tree. Build a ring rule that always finds a homeβand moves only a small group when one tree sleeps.
π§ Before we start
At the sakura gate, you used a token to give each request a steady identity. Today, each firefly name also gets a steady spot. Consistent hashing places names and trees on one ring, then walks clockwise to the next tree.
Arrange the routing program
Tap three visual instruction blocks in the safe order. A firefly needs a ring spot before it can search for a tree.
Route three fireflies
Tap each firefly. Its name always lands on the shown spot; the rule walks clockwise to the first tree.
OAKπ
MUSHROOMπ²
WILLOWβ¨
LUMAβ¨
PIPβ¨
NOVA
Let one tree sleep
When Oak sleeps, only the fireflies whose next tree was Oak need a new home. Everyone else stays put.
BEFORE
Five firefly groups
AFTER OAK SLEEPS
Tap the sleeping tree
Debug the backwards sprite
A lost sprite walks counterclockwise and reaches Willow, but its first clockwise tree is Oak. Repair the direction rule.
π What you learned
- Consistent hashing places both names and homes around one ring.
- A name always turns into the same starting spot.
- The program walks clockwise to choose the next home.
- One shared direction makes routing predictable.
- When a home disappears, only its nearby group moves.
- Moving less work helps a changing system stay calm.