Hi guys, this is a correct group to talk about some implementations and
features regarded libketama ? if no stop here ;)

Today when I red the source code of libketama [1] to undertand how works and
how consistent hashing works of corse I have found some "hot"
characteristics with proably errors. Well may be I m in a mistake ;)

Algorithm follow this points :

- Create one vector of integer points sized in 160 * num_servers ( this 160
hardcode value may be have been seen good with heuristic proves )

- All of servers has one weight regarded the server memory and all memory.
  Perhaps, with three servers with 1, 1, 2 Gb, first server has a 0.25 of
weight, second also and third 0.5

- Algoritm itereate for all servers and with weight calcule the  maxium
points reached for server. Number of points iterated are regarded to weight,
how many weight more points you can reached. For each iteration create a
"random" integer points ( md5(str_ip + "-" + num_iteration )


At the end of algorithm you have one vector with n integers associated to
servers, servers with more weight will have more points. If you think in
original explanation in [2] the cyrcle will have a lot of points where one
server is repeated.

Ok but whats happend when one server goes down, for example second server ?

Algorithm recalculates another time all contium, with all servers without
one.  Now we have two servers one with 1 Gb and second with 2 Gb - the
others server is down.
The weight of all serers will be change to 0.33 and 0.66. And the number of
points assigned to each server will be change also !!

This change can be problematic because now the new continium has a more
points for server A and server B , and probably keys that after this change
was assigned in server A now can be assigned  in server B. And viceversa !

Without weight algoritm works fine.


[1] svn://svn.audioscrobbler.net/misc/ketama/
[2]
http://www.last.fm/user/RJ/journal/2007/04/10/rz_libketama_-_a_consistent_hashing_algo_for_memcache_clients
-- 
--pau

Reply via email to