I have a question about memcached distribution across nodes. We have 20 memcached nodes with 200GB memcached on each. Our apps are PHP apps.

$memcache->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);

What will be the result if the following things happen :

  1. Node 2 goes down
  2. A key "XXX" which is on node 2 is asking to be setted

    => I suppose the key will be written on another node, maybe node 5

  3. Node 2 comes back up
  4. A try to get key "XXX".

Which node will memcached get the key from : node 5 or node 2 ?

1 Answer 1


The node is chosen based on a hash algorithm that decides how to distribute keys amongst available hosts. You can read up on the two types of distribution the PHP client library offers, search for Memcached::DISTRIBUTION_MODULA and Memcached::DISTRIBUTION_CONSISTENT distribution algorithms.

As nodes are added or removed it may result in a get/store for any particular key landing in the same or different node, but ultimately it won't matter. You still would populate a key upon a cache miss in the new node, and any old value for the same key in other nodes would simply not be accessed and expire and go away.

In terms of storage Memcache is more of a mattress than a bank.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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