[mod_python] Session data

Chris Hagner CHagner at fool.com
Tue May 29 13:08:01 EST 2001


In my experience, the quickest way to ensure that your web application
scales poorly is to mis-use server-side user sessions (thereby agreeing with
Grisha).  Now, that being said, not everyone needs this level of scalability
AND user sessions are a standard part of almost every-single web application
platform (ASP, Servlets/JSP, ColdFusion, etc.) commercially available.

BTW, I've found that most non-Apache-based web developers (of which I used
to be one :-) are completely ignorant of the realities of running in a
multi-process server.  They generally take for granted the user sessions
built into whatever app server they're using and find it mentally
challenging to truly believe they can live without such functionality.

I like the idea of having a standard interface to whatever mechanism is
responsible for persisting user session information, but I cringe at
incorporating an implementation with mod_python.  Basically, for some people
a pickled object will work fine.  For others a database-based session system
works best.  And some (Grisha) will only be happy with the use of
cookies/urls.

As for multiple-server user sessions, there are some solutions available in
the non-Python space (most of the ones that I've seen use either a database
(ugh :-) or a solution along the lines of Java's RMI to keep the session
pool's in sync.  In either case, it is a non-trivial problem/solution and is
best avoided (following the KISS principle).

You might want to check out WebWare (webware.sourceforge.net) as an expample
web framework that has some session support.  I think they pickle objects to
the file system.  There are some other python-based cgi frameworks that also
support user sessions, but just be aware of how far such solutions will/will
not take you.

Chris

-----Original Message-----
From: Bo Lorentsen [mailto:bl at netgroup.dk]
Sent: Tuesday, May 29, 2001 8:50 AM
To: Gregory (Grisha) Trubetskoy
Cc: mod_python at modpython.org
Subject: Re: [mod_python] Session data


"Gregory (Grisha) Trubetskoy" wrote:

> In *my* opinion, trying to maintain state within the server is not
> scalable and should be avoided. State should be maintained on the client
> side with cookies and url's.

If this is so, shouldn't there be some sort of interface for this ? Or is
this something I should have known more about if I had known the Apache
server better ?

> Since Apache 1.3 runs multiple processes, it is impossible to share memory
> between them and therefore maintain state in the server.

Aha, so this is why the JavaServer make its own service, the Apache direct
requests to !

> But even with the new Apache 2.0 (which mod_python does not yet support),
> which will be multithreaded, I would stay away from putting state on the
> server. If I ever decided that my site is too busy and needs balancing
> across multiple servers, I'd be in trouble... Also consider situations
> when a request may never reach a server because of some cache inbewteen.

You absolutely got a point there.

I just need to gain knowledge about some other ways of maintaining session
data, as until now, I thought that a cookie were just a session reference
number of a kind.

/BL

_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://www.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list