Apache (FCGI?) session distribution
Hopefully this is a simple question, since I'm fairly new to the inner workings of Apache. For those unfamiliar with FCGI, it creates a cgi process that continues running between requests, effectively creating a instance that 开发者_Go百科lasts as long as the user needs. It does this by starting an executable cgi file and directing future requests into that running program (as I understand it).
My question is this: Is there a way to have apache create a new instance of this program for every new user (as determined by cookies, IP address, whatever) and then redirect subsequent requests from that user to the same process they initialized? I.E.
user1 requests test.fcgi
user1 creates PID 100
user2 requests test.fcgi
user2 creates PID 101
user1 requests test.fcgi
user1 directed to running PID 100
user2 requests test.fcgi
user2 directed to running PID 101
If this requires new modules or already existing programs, that's fine. If it's something I'll have to code myself, could you point me in the right direction to start?
For details: I'm running apache 2.2.12 on an EC2 machine with libapache2-mod-fcgid installed from the ubuntu repositories.
Thank you
No, you don't get session affinity with FastCGI, and since (in the configuration that's nearly always used), all of the child processes are listening on the same socket and relying on the kernel to distribute connections to them, there's no trivial way to add this in a webserver. You would need to have each child process treated as its own backend, with its own socket, before you could do session affinity to child processes.
Better idea: don't keep the state needed for users in individual processes; persist it outside of the process. That's pretty much what sessions are for.
精彩评论