0

I can't find documentation on the behavior of ActiveSupport::Cache::MemCacheStore anywhere, and I'm hoping someone here can shed some light. The rdoc says:

"Clustering and load balancing. One can specify multiple memcached servers, and MemCacheStore will load balance between all available servers. If a server goes down, then MemCacheStore will ignore it until it comes back up."

Ok. I want the last feature, so if a memcache server goes down the whole stack doesn't fail. But I need to understand the load balancing feature. I assume it doesn't just round robin requests, as that would result in unnecessary cache misses, it seems. Also, I'm using memcache for sessions, so I wouldn't want someone logged in to suddenly not have a session because memcache client "load balanced" that request to a server that doesn't have that session...

Can someone help me understand how the "load balancing" feature works?

Joshua
  • 5,336
  • 1
  • 28
  • 42

1 Answers1

3

As I understand it it uses a hashing mechanism to determine which memcache server to send requests to. The hashing mechanism uses the key if the key value pair being stored thus when the value is requested by key the same hashing method will tell rails the correct memcache server to fetch the data from.

This means that if a memcache server dies you will loose the proportion of data that is cached on it (ie in a 3 server config if 1 server dies you will loose 33% of your cache)

EDIT: See http://www.ruby-forum.com/topic/100104 for a much better explanation of that than I've just given.

Chris Bailey
  • 4,126
  • 24
  • 28