[jifty-devel] Moving away from Apache::Session, into the database

Alex Vandiver alexmv at bestpractical.com
Wed Apr 26 02:25:32 EDT 2006

  We're working on moving away from using Apache::Session for session
management, and instead into doing it ourselves in the database.  This
is so we can better store (and garbage collect) large numbers of
continuations[1], as well as to alleviate session lock contention which
modern AJAX applications generate[2].  This will be done by storing each
session variable as a row in an internal _jifty_sessions table.
  The slight problem with this lies in upgrading the schema.  I'm
hesitant to simply push the changes, as they will break all existing
jifty databases, as they lack the necessary table.  The right thing to
have done would be to store the version of jifty which created the
schema, in the database.  We'll probably change the internal _db_version
table into a _jifty_metadata table, but that change itself has a
chicken-and-egg problem.  The proper solution is probably an upgrade
script which will allow us to bootstrap around this problem.
  In any case, the in-database session handling code is attached as an
SVK patch, in case people want to comment, or play with it before it
hits the main branch.
 - Alex

[1] Right now, writing out a session is O(n) with the number of
continuations.  This can get to take quite a lot of the processing time
as the number of requests grows.
[2] AJAX applications butt heads with the old rule that you write-lock
the session when a request came in, and release the lock when the
request ended.  This is because there can be multiple concurrent
requests to the webserver, all with the same session.  The DB-backed
session handler takes advantage of the fact that we rarely actually have
read-write race conditions between concurrent processes on the same key
of a session, and breaks each key in a user's session into a separate
row.  This makes all of the common actions O(1), and means we can do
away with locking.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: session-db.patch
Type: text/x-patch
Size: 18207 bytes
Desc: not available
Url : http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20060426/7229246b/session-db.bin

More information about the jifty-devel mailing list