How to maintain cache update on different memcached servers?

Sam G. ceptorial at comcast.net
Tue Oct 31 17:07:44 UTC 2006


On Oct 31, 2006, at 8:56 AM, Bash Coder wrote:

> When B goes down you have no failover memcache.  That's OK, because  
> you don't *need* it anyway - it's just a helper to take load off  
> your database.  If B fails your app goes directly to the database  
> for its data until the cache server B is back up.  When the server  
> comes back up, it starts to build it's cache again from scratch.
>

But what happens in this scenario: Webserver has a connection to  
memcached A and memcached B. It stores key 1 which hashes to A. The  
webserver loses the connection to A (A does not go down, the  
connection is simply lost). Next, the value for key 1 changes. The  
webserver tries to store the new key 1, it can't connect to A, so it  
is hashed to B, so it stores the key/value pair at B. The webserver  
manages to reconnect back to A. Now it tries to retrieve key 1. It  
hashes the key again now with servers A and B, key 1 is hashed to A,  
but A now contains stale data. Is the stale data returned? I  
understand memcache may not return any results, and that's okay  
because this is all assuming a database backend... but can memcache  
actually return incorrect data?

Thanks,
Sam




More information about the memcached mailing list