[PHP] Php application with session used in a cluster

2012-12-12 Thread Jan Vávra

Hello,
 we are considering to use a php on several application servers behind 
the apache mod_proxy_balancer. Our php app is using session cookies. And 
we would like to use session stickyness - once the user connects to app 
server X and gets the session cookie, all other request will be 
ballanced (reverse proxied) to the app server X. We have these 
theoretical possibilities:


1. Into each response add own Set-Cookie: Cluster-Node=blabla.X
When user continues requesting the apache balancer the balancer knows to 
which app server redirect. From the value of own cookie Cluster-Node= 
reads the value X identifying the app server X.
Problem: Does exist in the php framework something like .net post 
request handler?
For better understanding replace the word /post by //after/. So after 
the request is processed by the php application code the post request 
handler is fired and calls header(Cluster-Node=blabla.X)


2. Modify the php session management system.
We need to add to php session value string .X. Is there a way how to 
do it?


3. Write an own session management system for a single app server or for 
all of them.

The most work-intensive option ;-(

My resource is a paragraph from Apache mod proxy balancer manual
http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html

Some back-ends use a slightly different form of stickyness cookie, for 
instance Apache Tomcat. Tomcat adds the name of the Tomcat instance to 
the end of its session id cookie, separated with a dot (|.|) from the 
session id. Thus if the Apache web server finds a dot in the value of 
the stickyness cookie, it only uses the part behind the dot to search 
for the route. In order to let Tomcat know about its instance name, you 
need to set the attribute |jvmRoute| inside the Tomcat configuration 
file |conf/server.xml| to the value of the route of the worker that 
connects to the respective Tomcat. The name of the session cookie used 
by Tomcat (and more generally by Java web applications based on 
servlets) is |JSESSIONID| (upper case) but can be configured to 
something else.


And the last possibility is:
4. Can apache mod_proxy_balancer stick cookies by the session cookie name?
Each app server can have its own session.cookie_name=PHPSESSION-X. But 
it is a query for a different forum...


Can anybody give me an advice?

Thanks.
Jan.


Re: [PHP] Php application with session used in a cluster

2012-12-12 Thread Jim Lucas

On 12/12/2012 05:19 AM, Jan Vávra wrote:

Hello,
we are considering to use a php on several application servers behind
the apache mod_proxy_balancer. Our php app is using session cookies. And
we would like to use session stickyness - once the user connects to app
server X and gets the session cookie, all other request will be
ballanced (reverse proxied) to the app server X. We have these
theoretical possibilities:



[...]



Can anybody give me an advice?


Why not use database driven sessions?  Their are many examples on the 
net of how to setup such a system to replace the file based system used 
by default.




Thanks.
Jan.




--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php