[imp] memcached sessions

liam hoekenga liamr at umich.edu
Thu Nov 10 09:47:26 PST 2005


> And what if localhost dies?  Or you don't have tons of free RAM on 
> your local machine?

Well, my idea was that the cache on the local machine would somehow 
take precedence over the bigger cache.

But... I also didn't really understand how memcache worked at the time 
I made that suggestion.

> I think one of the dangers is trying to make one methodology fit into 
> another one, without making some adaptations in the process.  I read 
> through a lot of the memcached archives a few weeks ago and came away 
> with a realization that memcached does just what it says it does - it 
> caches data, to prevent (potentially slower) database lookups.

I had to write a script to step through all of the memcache servers in 
our pool and to locate piece of cached data to come to that 
realization.  I guess sometimes you just have to see how something 
works.

So, I have to agree with you.  It's a cache.  In it's intended use, it 
looks for a piece of data, and if it can't find it, it retrieves it 
from a database.  Something is either in the cache or not.

> So all that to say that what I think I've arrived at is:
> 1) memcached is a fast session store, if you can live with the lack 
> of fault-tolerance
> 2) extending memcached to be fault tolerant might not be worth the 
> effort - some sites have daemon uptimes of months on end, so it may 
> be stable enough.  I'd probably end up restarting Apache more times 
> than I would have to with memcached, when all is said and done.
> 3) The less layers of complexity, the better.  If I can get by with 
> libevent + memcached + PHP + PECL + PECL memcache (and I'm already 
> using PHP and PECL in the grand scheme of things) vs. libevent + 
> memcached + PHP + libmemcache + php-mcache, thats one less layer and 
> dependency that I have to deal with..

If I understand what you're saying, I think that the one thing that the 
libmemcache + php-mcache combo gives us is fault tolerance that the 
current solution in HEAD doesn't.  If a server drops out of the pool, 
you only loose the data on that server.  My experience is that the hash 
algorithm  isn't effected such that the loss of a server that all of 
the data is shuffled to new servers because the hash is calculated 
differently.

I'm running a small memcached on each of the webservers in my webmail 
pool.  If one of those machines goes down, I need
- the memcache session handler to handle the loss of a server w/o admin 
  intervention. I'm not removing the server from the conf files so  the 
session handler won't hang when it tries to contact the downed server.
- to not invalidate all the session data on the remaining memcache servers.
  Logging everyone out cuz we lost 1/15th of the memcache pool isn't
  acceptable

I'm pretty sure that php-mcache extension does fulfills these needs.  I 
haven't played with the stuff in HEAD, but I /think/ that it doesn't.  
Please correct me if I'm wrong.

Liam


More information about the imp mailing list