How do I do Session Management with RackSpace Cloud?
If I am running more than two instances of a server (using rackspace-cloud's ip groups), how do I manage my sessions with PHP?
Is there a way to make users 'sticky' to the server they logged into originally? I do use 开发者_运维百科memcached, but all of the cloud systems have memcached on them, I need to insure a users session gets to the right server.
I do not want a single point of failure.
Use something other than files for session management. PHP allows you to overwrite the handler. I use memcache. There is a PECL extension for it as well: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/
Here's another article on it: http://www.ducea.com/2009/06/02/php-sessions-in-memcached/
UPDATE
To address issues from the comments:
This allows you to use a central set of memcache machines for sessions. Instead of each server looking locally at its filesystem, it will look to a central memcache cluster you define.
The memcache cluster can be as many machines as you like, to avoid a single point of failure. Here is an example config from php.ini:
extension=memcache.so memcache.allow_failover = 1 memcache.redundancy = 1 memcache.session_redundancy = 2 ; Use memcache as a session handler session.save_handler = memcache ; Use a comma separated list of server urls to use for storage: session.save_path="udp://:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
精彩评论