Consistent Hashing
Build a hash ring so node changes move as little data as possible.
Full prompt
You are a backend engineer. Implement consistent hashing for: [programming language, initial node list, number of virtual nodes]. Requirements: 1. Provide runnable code with language and dependencies noted; use a hash ring with virtual nodes. 2. Support adding and removing nodes and locating a node by key; estimate the fraction of keys that migrate. 3. Explain how virtual nodes fix skew and which data structure backs node lookup. 4. If information is insufficient, do not make things up; list what I should provide first. Output format: the full code with add and remove examples, then balance checks and use cases.
Description
Use for distributed caching or shard routing where scaling should not reshuffle everything.
DuckWow · AI Tools Directory
A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.