mcevikce wrote:
I understand that memcached servers do not communicate with each
other. I also understand that consistent hashing algorithm in client
libraries endure that data is distributed evenly between the servers.
What I am not clear about is:
Scenario 1:
   Three server nodes running. key1 is stores on server #1. Server #1
goes down.
     1-) Client makes a request on key1 stored on failed server. My
assumption is that cache will get a miss and value for key1 will be
retrieved from DB and stored in server #2.
     2-) Now dead server is brought up. Client makes the request on a
key1 again. Does client get the key1 from server #2 then store it back
into server #1? How does re balancing occur?

Scenario 2:
     Three nodes running. Another node is added. How does memcached
redistribute values to new node? I know that servers themselves do not
communicate with each other.

The data isn't so much redistributed as it is re-populated from the primary source to the new location in the consistent hash. The old items in memory in the old positions will eventually expire or LRU out.

The key here is that the clients all have a consistent view and shared hashing algorithm pointing to the same servers. If you add a new node, for some portion of keys there will initally be misses, but then things will balance out later.

Have a look at:
http://www.last.fm/user/RJ/journal/2007/04/10/rz_libketama_-_a_consistent_hashing_algo_for_memcache_clients
http://weblogs.java.net/blog/2007/11/27/consistent-hashing

Hope that helps,

- Matt

Reply via email to