[mod_python] Sessions in a load balanced arena

Mike Looijmans nlv11281 at natlab.research.philips.com
Wed Feb 15 01:33:28 EST 2006

If you can - avoid sessions alltogether. You do not need sessions for simple user authentication, a 
cookie will do that very well.

Because sessions are often so simple to use (as in mod_python), many pages use them as a 
tool-for-everything. As an alternative, you can use forms and hidden fields (I have a demo here that 
creates pages with possibly hundreds of fields storing intermediate data - all state is maintained 
on the page itself), or you can append path info to your url, like 
/my/server/handle.py/user/mike/mode/rw (note that a URL may be up to 6000 characters long).

Having said that, yes, storing session data in a central DBMS and retrieving/storing it there works 
very well. In general, a DBMS is faster than a filesystem for this kind of thing. And like HTTP 
servers, DBMSs scale well.

Mike Looijmans
Philips Natlab / Topic Automation

Peter Sanchez wrote:
> Hey all.. Quick question:
> How can sessions be managed in a load balanced scenario. Say, between  3 
> hosts all having traffic directed to it. From what I understand,  the 
> session data is stored locally on each host. When a new visitor  reaches 
> hostA and gets a session, hostB won't know about it.
> Sounds like Cookies are the way to go for a load balanced solution.  
> Using the cookie to save an identifier and keeping track in a  database 
> of some sort. Is my thinking wrong?
> Thanks,
> Peter
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list