Simple basic explanation of a Distributed Hash Table (DHT)

前端 未结 3 637
陌清茗
陌清茗 2021-01-29 16:51

Could any one give an explanation on how a DHT works?

Nothing too heavy, just the basics.

3条回答
  •  庸人自扰
    2021-01-29 17:42

    I'd like to add onto HenryR's useful answer as I just had an insight into consistent hashing. A normal/naive hash lookup is a function of two variables, one of which is the number of buckets. The beauty of consistent hashing is that we eliminate the number of buckets "n", from the equation.

    In naive hashing, first variable is the key of the object to be stored in the table. We'll call the key "x". The second variable is is the number of buckets, "n". So, to determine which bucket/machine the object is stored in, you have to calculate: hash(x) mod(n). Therefore, when you change the number of buckets, you also change the address at which almost every object is stored.

    Compare this to consistent hashing. Let's define "R" as the range of a hash function. R is just some constant. In consistent hashing, the address of an object is located at hash(x)/R. Since our lookup is no longer a function of the number of buckets, we end up with less remapping when we change the number of buckets.

    http://michaelnielsen.org/blog/consistent-hashing/

提交回复
热议问题