cakePHP + php5-fpm + memcached = lots of open TCP connections to memcached? <p>I'm pretty sure this is a CakePHP bug, but figured someone here may have run across this and know how to fix. FYI - I've created a <a href="http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/1705-cake-138-memcacheengine-does-not-close-connection" rel="nofollow">ticket</a>.</p> <p>I run PHP as fastcgi under nginx via php5-fpm. When I use 'Memcache' as the engine for my cake cache, I notice that TCP connections are not closed. I notice that cake's <a href="http://api.cakephp.org/view_source/memcache-engine/#line-198" rel="nofollow">MemcacheEngine</a> does not ever call PHP <a href="http://www.php.net/manual/en/memcache.close.php" rel="nofollow">memcache::close()</a>.</p> <p>For people who run PHP under non-fastcgi processes, I think this is OK as at the end of the PHP request the process ends, and "breaks" the TCP connection between PHP and memcached.</p> <p>Using php5-fpm this is not the case, as the PHP process stays running to be re-used.</p> <p>Does anyone know a best practice for this? I'm thinking of modifying the CakePHP code to close the connection at the end of processing - but I'm wondering if there is a better way.</p> <p>Note: CakePHP's MemcacheEngine does NOT use <a href="http://www.php.net/manual/en/memcache.pconnect.php" rel="nofollow">pconnect</a>.</p> <p>My version info:</p> <pre><code>Ubuntu 10.10 64bit PHP 5.3.3 PECL memcache 3.0.5 memcached 1.4.5 cakephp 1.3.8 </code></pre>