It has recently been discovered that Zend_Session DbTable SaveHandler is implemented in a way that is not very optimized for high performance, so I am exploring the switch to using Memcache for session management.
I found a decent template / class for modifying Zend_Session SaveHandler in my boot block from DbTable to Memcache here and added it to my web application.
In my bootstrap, I changed SaveHandler as follows:
FROM:
Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
TO:
Zend_Session::setSaveHandler(new MyApp_Session_SaveHandler_Memcache(Zend_Registry::get("cache")));
So my init session is as follows:
Zend_Loader::loadClass('MyApp_Session_SaveHandler_Memcache'); Zend_Session::setSaveHandler(new MyApp_Session_SaveHandler_Memcache(Zend_Registry::get("cache"))); Zend_Session::start(); // set up session space $this->session = new Zend_Session_Namespace('MyApp'); Zend_Registry::set('session', $this->session);
As you can see, the class provided from this site quickly integrates with a simple loadClass and changing SaveHandler in the boot block, and it works in my local dev env without errors (the web application and memcache are on the same system).
I also tested my web application hosted on local dev env with the remote memcache server in PROD to see how it works on cable and it seems to work fine too.
However, in my intermediate environment (which simulates production), my zend application is hosted on server1 and memcache hosted on server2, and it seems that almost every other request completely destroys certain error messages.
The error information received includes the message "the session is already running session.auto-start or session_start ()", and the second / connected indicates that Zend_Session :: start () received a connection that was rejected with "Error No. 8 MemcachePool :: get () "is involved in line 180 in the frame file .. /Zend/Cache/Backend/Memcached.php.
I confirmed that my php.ini has session.auto_start set to 0 and the only instance of Zend_Session :: start () in my code is in my bootstrap. In addition, I run my Cache, Db, and Helpers before the start of the session (to make sure my Zend_Registry :: get ("cache") argument to instantiate my new SaveHandler is valid.
I found only about two valuable resources for successfully using Memcache for Zend_Session, and I also looked at the ZF Zend_Cache_Backend and Zend_Session Advanced Usage documents, but I could not determine the source, why I get this error using Memcache or why it will not work sequentially with dedicated / remote memcache server.
- Does anyone understand this problem?
- Does anyone have any experience solving this problem?
- Does anyone have Memcache working in their ZF web application to manage the session in a way that they can recommend?
Please include all / all the Zend_Session and / or Zend_Cache settings that you made, or the other tricks or witchcraft that you used for this.
Thanks!