dongshi4078 2011-05-13 19:32
浏览 35
已采纳

cakePHP + php5-fpm + memcached =很多开放的TCP连接到memcached?

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 ticket.

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 MemcacheEngine does not ever call PHP memcache::close().

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.

Using php5-fpm this is not the case, as the PHP process stays running to be re-used.

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.

Note: CakePHP's MemcacheEngine does NOT use pconnect.

My version info:

Ubuntu 10.10 64bit
PHP 5.3.3
PECL memcache 3.0.5
memcached 1.4.5
cakephp 1.3.8
  • 写回答

1条回答 默认 最新

  • douan5151 2011-05-16 14:56
    关注

    Turns out MemcacheEngine uses Memcache::addServer() which by default uses persistence. It is correctly re-using the connections between my FPM children and my memcached pool.

    Cake has added a 'persistent' option now, to allow the overriding of the default behavior for those that wish: http://cakephp.lighthouseapp.com/projects/42648/tickets/1705-cake-138-memcacheengine-does-not-close-connection

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3