A consistent hashing ring is a common element in building distributed computing services. A consistent hash is made of a request identifier and then assigned to a node based on a distributed list of host identifiers which are also hashed and typically kept as a ring of hashes. The ring allows one to add and remove nodes dynamically and keep the distribution of requests balanced among them. Consistent hashing may also be used to shard database tables.
My implementation of a consistent hash ring first appeared for C++ in the ModernCLI codebase in July. I have since built a "consistent" conforming version in golang, in C# for dotnet, and, why yes, in rust too. There is now even a pure C implementation in minicrypt. As a C++ super-set toolkit, Kakusu naturally has a consistent implementation that lives on digests from other toolkits. Along the way I have learned more about what I both like and hate about each language and its ecosystem, too.
The basic idea is that each language implementation should produce the same results when using the same input data and digest algorithm, so you can write your distributed components in a mixture of languages and have it all work together. To give the hash digest more data to churn on I am considering introducing an option for salted rings, and I wish to do more extensive and realistic unit testing.
Top comments (0)