9

一致性hash算法

 3 years ago
source link: https://www.80shihua.com/archives/2676
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
一致性hash算法 | 梦回故里

一致性hash算法

我们都知道单机应用很简单,但是一旦涉及到多机应用,涉及到分布式,那么事情就会变得复杂,而一致性hash算法就是为了解决分布式中添加节点不造成大量节点数据重新分配的算法。

1997年,Karger在cache中首次提出一次性hash算法。

  1. 将服务器节点的hash分配到圆环上
  2. 求出存储数据的hash值映射到圆环上
  3. 根据映射的位置,顺时针查找第一个服务器节点存放数据
  • 平衡性,所有节点数据分布均匀
  • 单调性,缓冲区大小变化时,节点不需要重新分配
  • 平滑性,缓冲区改变应该不影响或者很少影响数据的重新分配
一致性hash

物理节点少的解决

当物理节点过少的时候,可以采用引入虚拟节点,增加hash的均匀分布。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK