Where does APC store its opcode and user variable cache?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 20:00:34

问题


The reason I ask is because when using top I don't see a process for anything like APC. So I assume that the memory usage would be accounted for in an apache process.

Is that the case, and does that mean that the memory APC is using is replicated in each apache process, thereby taking up potentially much more memory than what was originally assigned to it?

If this is the case would memcache be a better solution, even if it's not being used on multiple loadbalanced servers?


回答1:


APC uses shared memory to store its opcode cache. In the case of mod_php this memory is shared between all Apache processes. So a 30MB cache only takes up 30MB even if there are 5 Apache processes.

However, when using mod_php, each Apache process does waste a lot of resources as each process contains the PHP interpreter. Thus, when Apache serves static content (html, css, js, image files, etc) it uses a process with the full PHP interpreter loaded. To get around this, some people use FastCGI via mod_fastcgi or mod_fcgi. Using an opcode cache with FastCGI becomes a bit trickier.

There is currently no way to use memcache as an opcode cache. Even if there was, it would probably be slower than desired.




回答2:


Besides being an opcode cache, APC also provides shared memory. That strongly suggests that it has its own internal shared memory system similar to memcached.



来源:https://stackoverflow.com/questions/1120045/where-does-apc-store-its-opcode-and-user-variable-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!