In a web server cluster, how do you do guys keep the php sessions? I
mean, with Apache and mod_proxy_balanced you could have a cluster with
apache backend webservers but If a user is logged into an php app then
this user goes always to the same backend server and if that server goes
down then the session is invalid.
How to deal with sessions?
thanks in advance! cheers
Several options exist, but the most common is to store session data in a
database that can be accessed by all of the web servers. Alternatives
include using memcached but recently I read something that suggested
that can be problematic.
I believe the cluster support in Zend Platform includes this
functionality, so depending on your budget that may also be an option.
-Stut
Just a note: you could have either one of the web servers acting as the
"session" server which the other web servers use or, if need be, a
dedicated "session" server. I wouldn't imagine you'd need that though
unless your site's really busy.
--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
What do you mean by "session server"? How are you accessing the session
data on another server?
-Stut
I server dedicated (or it can also act as a web server, or the main web
server) to storing sessions.
> How are you accessing the session data on another server?
Usually by way of a database.
Via Memcached or mysql server which only holds session data.
Regards
Sancar
Ok, that's basically what I suggested. Just wanted to make sure there
wasn't another way I wasn't aware of.
-Stut
I know this is a PHP and not an Apache list but maybe someone is doing
this with web hosting...
cheers!
Stut escribió:
Not only is this a PHP list, but your problem is a PHP problem. I'm
shocked. No, really.
Apache does *not* get involved in sessions. Not at all.
You could put in a custom session handler using a prepended file. See
the php.ini configuration option auto_prepend_file. I think there are
also extensions available that drop in to replace the session extension
- suggest you search the PECL site for those (http://pecl.php.net/). Of
course you need to be aware that any PHP script can override both of
these options.
Just to clarify, you're building a shared hosting system that load
balances all sites across a cluster of web servers? If not, please
explain what it is you're actually trying to do.
-Stut
Stut escribió:
> Jorge González wrote:
>> Ok, you both are right but not what I need because web servers is for
>> shared hosting with PHP then each user choose the way to develop
>> their apps. Then one user maybe store sessions in DB but another one
>> not. This should be on Apache or OS side. It's because I talk about
>> ldirector, LVS and so
>>
>> I know this is a PHP and not an Apache list but maybe someone is
>> doing this with web hosting...
>
> Not only is this a PHP list, but your problem is a PHP problem. I'm
> shocked. No, really.
Ok :)
>
> Apache does *not* get involved in sessions. Not at all.
Well the question is I was dealing with an Apache mod_proxy_balanced and
plans to use LVS or ldirector for balancing between backend servers. I
didn't know about other solutions.
>
> You could put in a custom session handler using a prepended file. See
> the php.ini configuration option auto_prepend_file. I think there are
> also extensions available that drop in to replace the session
> extension - suggest you search the PECL site for those
> (http://pecl.php.net/). Of course you need to be aware that any PHP
> script can override both of these options.
Well, I'll see later, sounds great.
>
> Just to clarify, you're building a shared hosting system that load
> balances all sites across a cluster of web servers? If not, please
> explain what it is you're actually trying to do.
yes, that is, and sessions are important. Users's session must be
persistent in all cases: web server down, user jumpig between backend
web servers, etc
>
> -Stut
>
Indeed it is.
>> Apache does *not* get involved in sessions. Not at all.
> Well the question is I was dealing with an Apache mod_proxy_balanced and
> plans to use LVS or ldirector for balancing between backend servers. I
> didn't know about other solutions.
That doesn't change the fact that Apache does not get involved in
sessions. Nor does mod_proxy_balanced, LVS or ldirector. Sessions are a
PHP entity. The only part of them that leaves the PHP part of the
solution is the session identifier which travels in cookies and/or URLs.
>> Just to clarify, you're building a shared hosting system that load
>> balances all sites across a cluster of web servers? If not, please
>> explain what it is you're actually trying to do.
> yes, that is, and sessions are important. Users's session must be
> persistent in all cases: web server down, user jumpig between backend
> web servers, etc
In that case you need to make sure you explain to your users/customers
that they cannot use a custom session handler and expect it to work.
-Stut
race conditions aside I think they could use a custom handler that makes use
the [mysql?] database that comes with their account (I'm assuming that the DB
server is also centralized/replicated.) ... I agree with Stut that your going to
want to make information available about all this to your users/customers in
big cow-sized letters.
>
> -Stut
>