Memcached Hashing/Distribution Types-opracowanie

Nasza ocena:

Wyświetleń: 336
Komentarze: 0

Pobierz ten dokument za darmo

Podgląd dokumentu
Memcached Hashing/Distribution Types-opracowanie - strona 1

Fragment notatki:

memcached Hashing/Distribution Types
The memcached client interface supports a number of different distribution algorithms that are used in
multi-server configurations to determine which host should be used when setting or getting data from
a given memcached instance. When you get or set a value, a hash is constructed from the supplied
key and then used to select a host from the list of configured servers. Because the hashing mechanism
uses the supplied key as the basis for the hash, the same server is selected during both set and get
You can think of this process as follows. Given an array of servers (a, b, and c), the client uses a
hashing algorithm that returns an integer based on the key being stored or retrieved. The resulting
value is then used to select a server from the list of servers configured in the client. Most standard
client hashing within memcache clients uses a simple modulus calculation on the value against the
number of configured memcached servers. You can summarize the process in pseudocode as:
@memcservers = ['a.memc','b.memc','c.memc'];
$value = hash($key);
$chosen = $value % length(@memcservers);
Replacing the above with values:
@memcservers = ['a.memc','b.memc','c.memc'];
$value = hash('myid');
$chosen = 7009 % 3;
In the above example, the client hashing algorithm chooses the server at index 1 (7009 % 3 = 1),
and store or retrieve the key and value with that server.
... zobacz całą notatkę

Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz