memcached + apache::session::memcached
Richard 'toast' Russo
russor at msoe.edu
Wed Mar 23 20:40:58 PST 2005
On Tue, 22 Mar 2005, Matthew Lenz wrote:
> I'm curious if anyone has used memcached to implement a Java session
> like session system with perl. We have an application that due to some
> mis-design requires a separate dbi::mysql connection per request (this
> is in addition to the one connection it opens to communicate with the
> db).
Wow, that is pretty messed up... using the database for access control,
I'm guessing? (not that it's relevant)
> Also, due to deep nested structures we are automatically
> incrementing a top level key => value so that the session is always
> stored back to the db if it is opened. None of this would be required
> normally, but we are in a load balanced environment and have experienced
> race conditions. We have three machines that handle this application
> and its entirely possible that one http application request from a
> customer can arrive to a different machine than the previous request.
>
> I'm looking for a solution similar to java's session (servlet/jsp) where
> the given session and its data is migrated to and from different servers
> automatically. It almost seems like memcached +
> apache::session::memcached was designed for this purpose but I'm not
> sure if I'm on the right track. Sorry if I missed some glaring
> documentation but hopefully someone can off some advice.
>
It seems like memcached will be a good fit. I'm not familiar w/
apache::session::memcached though.
> Does memcached migrate its data between a cluster of servers? I'm
> looking for a simple drop in replacement where the local webserver runs
> a memcached server which receives update/read session requests and then
> migrates the data to the other webserver's memcache servers.
>
>
memcached segments the information over the cluster. Assuming all
memcached daemons are running and all the clients have the same config,
all the clients will use a given server for the same key. It is important
to remember that the memcached cluster is just a cache not a backing
store, and may not be coherent while daemons are transitioning from down
to up. (Since each client individually keeps track of server failures,
and individually tries to reconnect, there are times when clients may
disagree about which server a key is stored on).
In your environment, you probably would want to run the memcached daemon
on all three webservers, so you can have a larger total cache.
toast
More information about the memcached
mailing list