Brazzford
Новичок
Здравствуйте! Я изучаю Memcached, и столкнулся с тем, что не могу представить как работает consistent hashing. Я нашёл такую информацию:
* Take your list of servers (eg: 1.2.3.4:11211, 5.6.7.8:11211, 9.8.7.6:11211)
* Hash each server string to several (100-200) unsigned ints
* Conceptually, these numbers are placed on a circle called the continuum. (imagine a clock face that goes from 0 to 2^32)
* Each number links to the server it was hashed from, so servers appear at several points on the continuum, by each of the numbers they hashed to.
* To map a key->server, hash your key to a single unsigned int, and find the next biggest number on the continuum. The server linked to that number is the correct server for that key.
* If you hash your key to a value near 2^32 and there are no points on the continuum greater than your hash, return the first server in the continuum.
If you then add or remove a server from the list, only a small proportion of keys end up mapping to different servers.
Особенно мне не понятно “Hash each server string to several (100-200) unsigned ints”
Это значит Hash(1.2.3.4:11211) = 3412h122aa… получим число из 100-200 цифр в результате? И кладём это число в диапазон от 0 до 2^32, но 2^32 это число из 10 цифр, и как я помещу число из 100-200 цифр? Можете, пожалуйста объяснить, и привести пример, буду очень благодарен, а то никак не получается понять.
* Take your list of servers (eg: 1.2.3.4:11211, 5.6.7.8:11211, 9.8.7.6:11211)
* Hash each server string to several (100-200) unsigned ints
* Conceptually, these numbers are placed on a circle called the continuum. (imagine a clock face that goes from 0 to 2^32)
* Each number links to the server it was hashed from, so servers appear at several points on the continuum, by each of the numbers they hashed to.
* To map a key->server, hash your key to a single unsigned int, and find the next biggest number on the continuum. The server linked to that number is the correct server for that key.
* If you hash your key to a value near 2^32 and there are no points on the continuum greater than your hash, return the first server in the continuum.
If you then add or remove a server from the list, only a small proportion of keys end up mapping to different servers.
Особенно мне не понятно “Hash each server string to several (100-200) unsigned ints”
Это значит Hash(1.2.3.4:11211) = 3412h122aa… получим число из 100-200 цифр в результате? И кладём это число в диапазон от 0 до 2^32, но 2^32 это число из 10 цифр, и как я помещу число из 100-200 цифр? Можете, пожалуйста объяснить, и привести пример, буду очень благодарен, а то никак не получается понять.
