blu.org  wiki

PHP web clusters and session information

View: New views
6 Messages — Rating Filter:   Alert me  

PHP web clusters and session information

by markw-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are there any admins/architects that have multiple web servers using PHP
and are sharing sessions.

I have an open source project I've been trying to get going for a while
now and I'd like to solve the major issues for this type of deployment.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss

Re: PHP web clusters and session information

by markw-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> On Wed, May 14, 2008 at 11:39 AM,  <markw@...> wrote:
>> Are there any admins/architects that have multiple web servers using PHP
>>  and are sharing sessions.
>>
>>  I have an open source project I've been trying to get going for a while
>>  now and I'd like to solve the major issues for this type of deployment.
>>
>>  --
>>  This message has been scanned for viruses and
>>  dangerous content by MailScanner, and is
>>  believed to be clean.
>>
>
> Yes, you have two options.  Either use file sessions and store the
> sessions on one of the servers and mount that directory via nfs to the
> other servers.  But I recommend against this.  Or re-write your code
> to store the sessions in the database, that way no matter what
> database you hit, you'll be pulling the session data from the db.
>
> There are tons of PHP examples out there of how to write your own db
> sessions using session_set_save_handler
> http://us2.php.net/manual/en/function.session-set-save-handler.php  Or
> what I did was to use PEAR::Http_Session2
> http://pear.php.net/packages.php?catpid=11&catname=HTTP

Well, as an introduction, I have a small session server system that
implements locking, session caching, etc. I have been using it on my web
sites for close to a decade now and the interface extension used to be
part of the PHP general distribution.


Tell me what you think about this:
http://www.mohawksoft.org/?q=node/36

>
>
> --
> -matt
>


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss

Re: PHP web clusters and session information

by Matt Shields :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, May 14, 2008 at 11:39 AM,  <markw@...> wrote:

> Are there any admins/architects that have multiple web servers using PHP
>  and are sharing sessions.
>
>  I have an open source project I've been trying to get going for a while
>  now and I'd like to solve the major issues for this type of deployment.
>
>  --
>  This message has been scanned for viruses and
>  dangerous content by MailScanner, and is
>  believed to be clean.
>

Yes, you have two options.  Either use file sessions and store the
sessions on one of the servers and mount that directory via nfs to the
other servers.  But I recommend against this.  Or re-write your code
to store the sessions in the database, that way no matter what
database you hit, you'll be pulling the session data from the db.

There are tons of PHP examples out there of how to write your own db
sessions using session_set_save_handler
http://us2.php.net/manual/en/function.session-set-save-handler.php  Or
what I did was to use PEAR::Http_Session2
http://pear.php.net/packages.php?catpid=11&catname=HTTP


--
-matt

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss

Re: PHP web clusters and session information

by ref-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


we have three front end web servers that serve millions of pages a month via apache2/php5, and
use an NFS server to hold all session information. We had to do this as the
front end servers are behind an SNMP balanced bigIP loadbalancer. we did some tests
first and for us it proved faster to get the flat files from NFS than to get the
session data from a shared DB (though I must add that the NFS mounted server is
ALSO the DB server, so it was actually a good test).

Richard



On Wed, 2008-05-14 at 11:39 -0400, markw@... wrote:
> Are there any admins/architects that have multiple web servers using PHP
> and are sharing sessions.
>
> I have an open source project I've been trying to get going for a while
> now and I'd like to solve the major issues for this type of deployment.
>


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss

Re: PHP web clusters and session information

by cmarko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I concur with Richard that the simplest method I have found is to simply
change session.save_path in your php.ini file to an NFS mount.  In my own
benchmarks, under a moderate simulated web load with hosts mounted against
the NFS share this performed much better than when trying to use a rather
simple method of storing it in a MySQL back-end (there is of course a lot
of room for optimization on the later which I did not consider at the time
as was looking for simplicity).  This seemed to peak at around 6 concurrent
web hosts against the NFS mount point, though I only had 7 physical hosts
to play with and so don't have insight into the drop-off beyond 7.  I can
probably dig out my project paper detailing the specs under this testing if
you think it might be of benefit to you.  

In theory if you used iSCSI on the back-end for the shared storage with a
clustered file system (I am thinking GFS, as I don't believe OCFS is
designed to perform well with the way PHP stores the session files) you
could scale this well beyond 6 hosts without suffering any performance
degradation.

If you have the luxury of a BigIP, then you can start to do clever things
such as using embedded cookies to leverage sticky sessions in pinning
someone to a specific host in the cluster, etc.  Of course the expense of
such puts out of reach of most open source projects and hobbyists.

Best of luck!
Chris

On Wed, 14 May 2008 17:46:11 -0400, ref <tbs@...> wrote:

> 
> we have three front end web servers that serve millions of pages a month
> via apache2/php5, and
> use an NFS server to hold all session information. We had to do this as
> the
> front end servers are behind an SNMP balanced bigIP loadbalancer. we did
> some tests
> first and for us it proved faster to get the flat files from NFS than to
> get the
> session data from a shared DB (though I must add that the NFS mounted
> server is
> ALSO the DB server, so it was actually a good test).
>
> Richard
>
>
>
> On Wed, 2008-05-14 at 11:39 -0400, markw@... wrote:
>> Are there any admins/architects that have multiple web servers using PHP
>> and are sharing sessions.
>>
>> I have an open source project I've been trying to get going for a while
>> now and I'd like to solve the major issues for this type of deployment.
>>
>
>
>


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss

Parent Message unknown Re: PHP web clusters and session information

by markw-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Date: Thu, 15 May 2008 19:52:20 -0500
> From: <cmarko@...>
> Subject: Re: PHP web clusters and session information
> To: ref <tbs@...>
> Cc: L-blu <discuss@...>
> Message-ID: <ff7a2c351635d134a265c7840e586bbd@localhost>
> Content-Type: text/plain; charset="UTF-8"
>
> I concur with Richard that the simplest method I have found is to simply
> change session.save_path in your php.ini file to an NFS mount.  In my own
> benchmarks, under a moderate simulated web load with hosts mounted against
> the NFS share this performed much better than when trying to use a rather
> simple method of storing it in a MySQL back-end (there is of course a lot
> of room for optimization on the later which I did not consider at the time
> as was looking for simplicity).  This seemed to peak at around 6
> concurrent
> web hosts against the NFS mount point, though I only had 7 physical hosts
> to play with and so don't have insight into the drop-off beyond 7.  I can
> probably dig out my project paper detailing the specs under this testing
> if
> you think it might be of benefit to you.
>
> In theory if you used iSCSI on the back-end for the shared storage with a
> clustered file system (I am thinking GFS, as I don't believe OCFS is
> designed to perform well with the way PHP stores the session files) you
> could scale this well beyond 6 hosts without suffering any performance
> degradation.
>
> If you have the luxury of a BigIP, then you can start to do clever things
> such as using embedded cookies to leverage sticky sessions in pinning
> someone to a specific host in the cluster, etc.  Of course the expense of
> such puts out of reach of most open source projects and hobbyists.

Would you be interested in trying an open source solution designed to
address this very problem?

http://www.mohawksoft.org/?q=node/36


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Discuss mailing list
Discuss@...
http://lists.blu.org/mailman/listinfo/discuss