2009/5/20 gert <[email protected]>: > > On May 19, 6:03 am, Graham Dumpleton <[email protected]> > wrote: >> Since I am not sure when I might get to blog and/or document this >> properly, here is a example configuration for how to implement sticky >> sessions, also referred to as session affinity, when using mod_wsgi >> daemon mode. >> >> Note that this just shows the basic concept. One could get more >> elaborate again by using 'prg' RewriteMap to use a separate program to >> determine which process should be used rather than it being random. >> You might for example choose process which is having least requests >> passed through to it for existing sessions. >> >> If anyone wants to discuss it, by all means go ahead. My expectation >> at the moment is that only those who know what session stickiness is >> all about might do that. In other words, I don't want to necessarily >> have to go explain what it is. If you don't know, then do a Google >> search on 'session affinity' or similar. >> >> # Define multiple process groups each with a single multithreaded process. >> >> WSGIDaemonProcess sticky01 processes=1 threads=10 display-name=%{GROUP} >> WSGIDaemonProcess sticky02 processes=1 threads=10 display-name=%{GROUP} >> WSGIDaemonProcess sticky03 processes=1 threads=10 display-name=%{GROUP} >> WSGIDaemonProcess sticky04 processes=1 threads=10 display-name=%{GROUP} >> WSGIDaemonProcess sticky05 processes=1 threads=10 display-name=%{GROUP} >> >> # Mount our WSGI application at the sub URL of '/sticky'. >> >> WSGIScriptAlias /sticky /Users/grahamd/Sites/sticky/site.wsgi >> >> # Specify a rewrite map which randomly selects one of the process groups. >> # The contents of the file should be: >> # >> # processes sticky01|sticky02|sticky03|sticky04|sticky05 >> # >> # That is, an entry for each of the named process groups in appropriate >> # format for a random rewrite map. >> >> RewriteMap sticky rnd:/Users/grahamd/Sites/sticky/processes.txt >> >> <Directory /Users/grahamd/Sites/sticky> >> >> # Lots of rewrite magic to follow. >> >> RewriteEngine On >> >> # Extract the name of the process group from cookie sent in the request. >> >> RewriteCond %{HTTP_COOKIE} process=([^;]+) >> RewriteRule . - [E=PROCESS:%1] >> >> # Validate the name of the process group and if not valid then set it >> # to one of the process groups randomly. >> >> RewriteCond %{ENV:PROCESS} !^sticky0[12345]$ >> RewriteRule . - [E=PROCESS:${sticky:processes}] >> >> # Set the cookie so that life time of the cookie always pushed out when >> # active. The cookie will expire after defined number of minutes of >> # inactvity and stickiness lost. Using a stickiness timeout of 60 minutes. >> >> RewriteRule . - [CO=process:%{ENV:PROCESS}:%{HTTP_HOST}:60:/sticky] >> >> # For the WSGI application, indicate that process group should be selected >> # based on value for the cookie or where appropriate as set randomly. As >> # extra security measure, even though we validate name above, limit what >> # process groups could be selected in case there might be others configured >> # for same server. >> >> WSGIRestrictProcess sticky01 sticky02 sticky03 sticky04 sticky05 >> WSGIProcessGroup %{ENV:PROCESS} >> >> </Directory> > > First stupid question: > Whats wrong with WSGIDaemonProcess sticky processes=5 threads=10 > display-name=%{GROUP} ? > They are identical processes, so why stick with process 1 when > processes 2 has nothing to do ?
First stupid response. Did you do any research about what sticky sessions or session affinity is intended to achieve? Can you explain what the benefit is of having subsequent requests from same user going back to the same process? > Second stupid question: > I fail to see how this can be used to cluster more then one apache > server ? Second stupid response. It is not intended to cluster Apache servers. > And final question: > Bubble drawings please :) OoOoOoOoO vs O O O O O :-) Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en -~----------~----~----~----~------~----~------~--~---
