phpapc

Difference between php-cli and php-fpm mode in regard to APC/APCu


The thought start from this question under php-cli mode:

PHP apc/apcu cache do not keep intermediate result while shmop do, why?

In this case, APC/APCu do not cache the intermediate result.

However, APC/APCu do cache the intermediate result just as the shmop when under php-fpm mode. So, what's the difference between php-cli and php-fpm when in regards to APC/APCu?


Solution

  • php-fpm ist running in its own process all the time. It can use apc because it uses continuously the ram over several requests. The memory is only released through the garbage collector or if you kill the fpm process. But the a CLI process lives only for one command and when its finished the memory is released. So apc cannot store any data over severel cli calls because it allocates new memory in the ram each call.