|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-18 15:21 UTC] martin dot minka at gmail dot com
Description: ------------ I am running huge site on a cluster of servers running PHP. The application is depending on sessions. Memcache session handler solved the speed bottleneck of storing session data to MySQL. The problem is that is the memcached server goes down (problem/maintenance) users loose their sessions and the site is unusable. Everything is redundant in cluster, only memcache session handling is risky at this moment. I think it should be easy to fix if you could add configuration option pairing servers together. Something like: session.save_path=tcp://<A1>:11211+tcp://<B1>:11211, tcp://<A2>:11211+tcp://<B2>:11211 would use servers A1 and A2 to generate the storage hash and put the same value to B1 and B2. Then if A1 is not available then B1 would be used. Same if A2 is not available then B2 will be used. What do you think ? Best regards, Martin Minka PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Hello Mikael, sorry to answer late, but I was traveling. This functionality is still top priority for website I am administering. To your suggestion: 1. I don't think the actual format of session.save_path is too complicated. I am sure that who is using memcache as session handler met more difficult semantic in his life ;) 2. I don't see value of load balancing (how I understand the actual usage of more servers in memcache session handler) if all writes will be sent to all servers when I add redundancy servers 3. format like: session.save_path=tcp://<A1>:11211 & tcp://<B1>:11211, tcp://<A2>:11211 & tcp://<B2>:11211 | tcp://<A3>:11211 & tcp://<B3>:11211 & tcp://<C3>:11211 where & defines redundancy and | defines balancing would make session handler very configurable, add redundancy and keep the benefits of load balancing 4. but I have to say, that I am not good advocate for the load balancing functionality. I would be fine to have only redundancy in the session handler. I never reached the situation that I would need to use load balancing of memcache. Any how...I am happy that some others and also you would like to see redundancy in memcache/PECL. You are the author and you did a great job in design and codding of this extremely useful library. The most important from perspective of high availability is to get redundancy implemented. Please, let me know what you decide and if you have time to implement it or if I should start to work on it. To make this discussion complete, I am including below my proposal which I sent you privately before. Sincerely, Martin Minka ************************************** I am interested mainly into redundancy of session data, but the changes would make this functionality available also to the functions exported to PHP. Benefits why to add this to the PECL library: A. redundant storage of data to more servers and fall back for read operation B. upgrade to new version of memcache server without downtime C. no need to add mysql support to achieve acceptable fault tolerance for data like web page caching and session handling D. no need to create session handlers written in PHP language to achieve this missing functionality My idea how to modify the code to achieve this: 1. add to struct mmc_t list of redundancy servers: mmc_t *backupServers; 2. add function Memcache::addBackupServer() which would fill backupServers variable, example: $mc = new Memcache(); $mc->addServer("<A1>", 11211); $mc->addBackupServer("<A1>", "<B1>", 11211); $mc->addServer("<A2>", 11211); $mc->addBackupServer("<A2>", "<B2>", 11211); $mc->addServer("<A3>", 11211); $mc->addBackupServer("<A3>", "<B3>", 11211); $mc->addBackupServer("<A3>", "<C3>", 11211); 3. in memcache.c(1098) do not stop with error, but try other servers in mmc->backupServers 4. implement the same loop as in (3) in mmc_exec_retrieval_cmd_multi 5. add loop to mmc_server_store, mmc_delete, mmc_flush to do the same on all backup servers 6. modify PS_OPEN_FUNC(memcache) in memcache_session.c to parse characters ',' and '|' as new servers and parse part after character '&' as new backup server. for example: session.save_path=tcp://<A1>:11211 & tcp://<B1>:11211, tcp://<A2>:11211 & tcp://<B2>:11211 | tcp://<A3>:11211 & tcp://<B3>:11211 & tcp://<C3>:11211 Of course in case of session handler in cluster the settings needs to be the same on all servers otherwise it will not work. I think it is not too much code to add and will also not cost too much speed lost if user will not define backup servers. All functions will also keep their compatibility. Hope you support it and that you will advice me how to proceed. I am able to add the code by myself, but I think it should be scored by the memcache authors.