PHP on several servers with session-sharing

Posted by Etu on Server Fault See other posts from Server Fault or by Etu
Published on 2012-06-12T08:05:53Z Indexed on 2012/06/12 10:41 UTC
Read the original article Hit count: 232

Filed under:
|
|
|
|

there's certanly other threads about this, but I have one more question.

We are about to scale the website at work to have more than one server. And we need to share the sessions between the servers.

We have been looking into different solutions, one in memcached and use Memcached as sessionhandler in PHP. That will probably work.

And the idea would be to run memcached on every machine and let all webservers access all other servers memcached servers, and then we have shared sessions between the machines, yay. (we have no resources to setup with sticky-sessions yet, that's a later project. we need this running, and we need this running now. and we will loadbalance with DNS for a starter)

But then... If I want to take one server down, say, for maintenance, or a server crashes, or whatever reason. I don't want the users to just loose their sessions and have to start from the beginning... That's why we need some kind of replication, which Memcached does not support.

Then I found http://repcached.lab.klab.org/ -- which has multi-master replication of memcached, which is great, and is what I want. But does it work with >2 machines? Say 3, 5, 10? For future scaling.

I also looked into redishttp://redis.io/ -- which also seems great, but is a bit more "shaky" with the php-session-handler support, and no multi-master-replication.

The thing is that I like to use memcached, but I want to be able to power down one of two boxes without loosing half of the sessions. Any suggestions?

© Server Fault or respective owner

Related posts about php

Related posts about load-balancing