Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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.