Consistent range-hashing is a technique used in distributed systems, either directly or as a subroutine for consistent hashing, commonly to realize an even and stable data distribution over a variable number of resources. We introduce FlipHash, a consistent range-hashing algorithm with constant time complexity and low memory requirements. Like Jump Consistent Hash, FlipHash is intended for applications where resources can be indexed sequentially. Under this condition, it ensures that keys are hashed evenly across resources and that changing the number of resources only causes keys to be remapped from a removed resource or to an added one, but never shuffled across persisted ones. FlipHash differentiates itself with its low computational cost, achieving constant-time complexity. We show that FlipHash beats Jump Consistent Hash's cost, which is logarithmic in the number of resources, both theoretically and in experiments over practical settings.
翻译:一致性范围哈希是一种用于分布式系统的技术,可直接使用或作为一致性哈希的子程序,通常用于在可变数量的资源上实现均匀且稳定的数据分布。我们提出FlipHash,一种具有恒定时间复杂度和低内存需求的一致性范围哈希算法。与Jump Consistent Hash类似,FlipHash适用于资源可按顺序索引的应用场景。在此条件下,它能确保密钥在资源间均匀哈希,且当资源数量变化时,仅会引发从已移除资源或向新增资源的密钥重新映射,而不会在持久化资源间产生洗牌。FlipHash凭借其低计算成本脱颖而出,实现了恒定时间复杂度。我们通过理论分析和实际场景实验证明,FlipHash在资源数量对数级增长的条件下,性能优于Jump Consistent Hash。