Nicolas Lehuen
nicolas at lehuen.com
Tue Feb 14 15:22:34 EST 2006
One very simple solution is to use sticky sessions. You simply configure your load balancer to select one host when a new IP makes a request, then stick to this host for an arbitrary period. This has some drawbacks, especially when considering large ISP with proxies, but it is definitely simple to implement (hardware load balancers can manage this). Then there are differents persistence strategies. You could store your session in a DBMS, for instance, though it slows down things a little bit. Writing a session storage using a SQL database is quite simple, I have written a proof of concept implementation using SQLite (which of course is not really usable in a multiple host context, but not much of the code would need to be changed with another DBMS). If that doesn't do the trick, then there's a whole bunch of tricks available, see for example what the people building Resin, a J2EE application server, have done : http://www.caucho.com/resin-3.0/config/sessions.xtp#Distributed-Sessions Unfortunately every distribution solution slows things done compared with single hosts solutions, so my advice would be to use sticky sessions and consider a DBMS-backed session system (switching between the two should only need changing your mod_python configuration) if you notice that your client's usage pattern result in unbalanced host usage. Regards, Nicolas 2006/2/14, Peter Sanchez <pjs at packet-addiction.org>: > 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 >
|