I've been thinking more on this issue and I've decided to implement a
database-backed SessionStore, specifically using MySQL memory (or heap)
tables. So the obvious first question is somewhat a repeat of David's -
Has anyone built a SessionDatabaseStore before? I did some more reading up on memcached and was scared off using it as a session store. No data is replicated, only hashed and stored to a particular server, which means that portion of the cache is lost when that server dies. You can wrap your own replication around memcached, to store the data twice with two different keys guaranteed to hash to different servers, but at that point I started looking at the built-in replication of MySQL instead. I need active sessions to remain available when web/app servers or db servers die. I like memcached for it's intended purpose though. Currently I'm using a home-rolled in-process caching scheme for frequently accessed db objects (i.e. singleton classes with dictionaries keyed by primary key of the db table). My intention when moving to the clustered environment was to use some kind of RPC between the appservers to delete an object from the cache when it is saved to the db. Then each appserver machine lazily updates as needed. This means each appserver potentially has the full cache, as opposed to memcached which spreads the cache over multiple servers. If the total object cache is small enough to fit in the usable memory of each appserver machine, then the per-machine cache will obviously always be faster (assuming the app has more cache hits than db writes!). But once the object cache grows beyond that single server limit, memcached looks pretty sweet, and the python API looks quite straightforward. Regarding the "hard to find bugs" when using SessionFileStore, they are probably related to multiple threads accessing and saving the session, with one clobbering the other. This can happen if thread A grabs session 1, then thread B grabs session 1, then thread A saves session 1, then thread B saves session 1 (overwriting thread A's save). This can never happen with SessionMemoryStore because it doesn't pickle the session objects - they are kept in memory in a dictionary - meaning that thread B "sees" thread A's changes as soon as they occur, because both threads point to the same object. A SessionStore backed by a database or memcached would exhibit the same functionality as the SessionFileStore. It's another concern I have to investigate with when migrating to a cluster... If others have input/experience with clustered appservers, or alternative session store algorithms, please speak out! Peace - Ben Hancock, David (DHANCOCK) wrote:
------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss |
- [Webware-discuss] Anybody made a memcached Sessi... Hancock, David (DHANCOCK)
- Re: [Webware-discuss] Anybody made a memcac... Ben Parker
- RE: [Webware-discuss] Anybody made a memcac... Hancock, David (DHANCOCK)
- Re: [Webware-discuss] Anybody made a me... Ben Parker
- RE: [Webware-discuss] Anybody made a memcac... Geoffrey Talvola
- Re: [Webware-discuss] Anybody made a me... Ben Parker
- Re: [Webware-discuss] Anybody made ... Chuck Esterbrook
- Re: [Webware-discuss] Anybody m... Ben Parker
- Re: [Webware-discuss] Anybody m... Nick Murtagh