2008年12月4日星期四

使用php apc模块需要注意的几点

在maillist中看到Rasmus的一段对于
php
APC模块的发言。作为APC的作者,他的见解应该是很有参考价值的。
APC will probably be 20-30% faster, but if you are writing to it frequently it can cause problems. The APC cache is best for things that change very rarely. And by very rarely I mean days, not hours or minutes.
Because of the way APC does an anonymous file-backed mmap where I unlink the file at startup to get process-death protection, it isn’t easy to get at the cache from a separate standalone command line script. That can be solved by mmap’ing slightly differently, but in the default config your approach won’t work.
-Rasmus
就是说APC不适合用于频繁写的场合,你最好只用它来保存那种几天都不会更改的内容。否则出了莫名其妙的问题就不好怎么解释了。
在以前的应用中,我确实有将apc用在频繁写的场合,偶尔会出现内存耗尽,进而引起所有http请求卡死,形式一发不可收拾整个服务器当掉。所以现在我仅仅用apc来缓存opcode的php代码,不在程序中显式的调用它,算是相安无事。
APC是什么
Alternative PHP Cache (APC)是一种对PHP有效的开放源高速缓冲储存器工具,它能够缓存opcode的php中间码。

没有评论:

发表评论

网站统计