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 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示