Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to the world of Memcached clusters

If I have a php web application that is using memcache - how does it does its hash and decide what node to check for a particular value to avoid having to check them all.

Bonus: How can I easily add a node in a way that avoids having to rebuild all the hashes.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Memcache clients know which node to check by hashing the key value. By default it uses the crc32 value of the key. In the old style, you would do something like

serverId = crc32(key) % servers.size

This meant that when you added a new server node, most things would remap to a different node.

For your bonus, use the new style where each node covers a linear rage of crc values determined by a randomly selected server number rather than every Nth value. This is called consistent hashing.

share|improve this answer
    
How can I tell if I am using the "old" version? Is there a process to switch to the "new" version without much disruption? –  ckliborn Mar 13 '12 at 5:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.