【翻译/介绍】jump Consistent hash:零内存消耗,均匀快速简洁,来自Google
简介 jump consistent hash是一种一致性哈希算法, 此算法 零内存消耗 , 均匀分配 , 快速 ,并且 只有5行代码 。 此算法适合使用在分shard的分布式存储系统中 。 此算法的作者是 Google 的 John Lamping 和 Eric Veach,论文原文在 http://arxiv.org/ftp/arxiv/papers/1406/1406.2294.pdf 完整代码: JumpConsistentHash 1 2 3 4 5 6 7 8 9 int32_t JumpConsistentHash ( uint64_t key , int32_t num_buckets ) { int64_t b = - 1 , j = 0 ; while ( j < num_buckets ) { b = j ; key = key * 2862933555777941757ULL + 1 ; j = ( b + 1 ) * ( double ( 1LL << 31 ) / double (( key >> 33 ) + 1 )); } return b ; } 输入是一个64位的key,和桶的数量(一般对应服务器的数量),输出是一个桶的编号。 原理解释: 下面byron根据论文的推导过程,做个翻译: jump consistent hash的设计目标是: 平衡性