Session affinity

Stanley Gambarin (
Wed, 04 Dec 1996 14:10:30 -0500

Message-Id: <>
To: Ben Davenport <>,,
Subject: Session affinity
In-Reply-To: Your message of "Wed, 27 Nov 1996 14:17:05 MST."
Date: Wed, 04 Dec 1996 14:10:30 -0500
From: Stanley Gambarin <>

> On another note, do you have any plans to implement connection affinity
> like that available in the Open Market server?
	Session affinity is the concept by which requests from the same
host [and possible same client] would be routed to the same FastCGI 
application.  As such, affinity can be used to cache results for improved
Web server and database access performance.  
	Unlike OpenMarket's Secure Web Server, Apache does not provide any
mechanism to track user sessions and as such has no support for session 
affinity.  In order to provide the aforementioned support, the following 
must be accomplished:
		- allow a mechanism by which a server assigns sessions ids.
		- route request to appropriate fcgi app based on session id.

	mod_fastcgi must not be concerned with how the sessions are actually 
defined.  All that mod_fastcgi must know is that there is a session id at a
certain place in the request.  (if it's not there, then session affinity is
	The function of mod_fastcgi is to hash the session id into nprocs-1,
where nprocs is the number of instances of the requested FastCGI app and route
the request into appropriate socket.
	Each instance of the FastCGI application process must have it's own
listening socket, instead of sharing one socket.
	FCGI_PROCESS_ID environment variable should be set to reflect
current process number [0..nprocs-1].

	Once again: mod_fastcgi MUST NOT IMPLEMENT SESSIONS, it must only
use them.  There is a number of ways to implement sessions and it is not our
responsibility to do that.  A few possible solutions are Cookies or 
assignment of session IDs based on the hostname and then using internal
redirection to send the session info.  Since Cookies might not be always
available and/or supported, it is not a general solution.  Instead, one might
implement a mod_session module that deals with sessions in a constant manner.

P.S. If someone plans to implement session affinity for the mod_fastcgi, please
write to the mailing list, so that we may discuss it and provide any 
suggestions, without duplicating the effort.


* Stanley Gambarin			Open Market Inc.		      *
* FastCGI (soon-to-be) Guru		245 First St. Cambridge MA 02142      *
*					(617) - 949 - 7487		      *
*					      *
* (school)    *
*		      *