I have two httpd servers running PHP on RHEL 5.7. Initially I was sharing PHP sessions between the servers using a common NFS share that was hosted on a third server. This was causing slow downs and eventually hangups on the httpd servers.
What is the best practice for sharing PHP session data between multiple httpd front end servers?
The vendor is recommending that I leverage load balancing connection persistence via a cookie or source IP, but I am concerned that a failure in one of the httpd servers will cause users to lose their session data and be logged out (for example).
Thoughts?
Thanks!
Either put your sessions into your (hopefully replicated) database, or use replicated memcached servers for your sessions.
This is a spin off from what I use for various customers:
It's currently ZF-based, but it can be easily extended to work with other frameworks. The idea is to use both Memcache and MySQL as a backup. Since it uses
ext/memcache
(a lot of people suggest to stick with 2.x-stable) I can add multiple servers have the extension replicates data across them.Not a 100% sure if this is the best idea, you could adchieve the same in userland code as well.
One lightweight option to test is Scache. But read it's intro, there's locking issues when using $_SESSION in multi server environment.