So I need to alter my session handling from file based (default) to cache based, so when I add a node to the cluster, the session data is accessible to any app node in the cluster.
My experience has always been to centralize cache nodes using a config file, in my case, cache.yml. With this file I identify 3 cache servers (vc-1, vc-2, vc3). Correct me if I am wrong, but as long as I use addServers call when creating my cache object, then use that cache object to set/get cache data, the data can be stored on any vc-* server, but as far as the app is concerned, it's a single (pooled) cache server. Example:
After reading the php memecacheD docs , I can easily switch the session handling by way of the php.ini file, but then I would have to configure (puppetize) the php.ini file to build out the server string list, anytime I want to add/remove a new cache server, in order to maintain this pooling effect.
So my question is, is there any other alternative other than implementing my own Session Handler , so that read/writes use the aforementioned cache object, to ensure a "pooled" caching effect, without having to edit the php.ini file?
I actually ended up using twemproxy , which is supposed to handle the addition/subtraction of memcached nodes based on health checks. It was easy to setup, basically created a DNS record for vcache, and had the code point to vcache:22122.
If using AWS, you can do the same thing but instead of twemproxy, setup an elasticache cluster, then create a CNAME dns entry which points to the elasticache endpoint. This way you don't have to make a single code change, as the CNAME dns entry pointing to the elasticache endpoint will still resolve to vcache.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.