Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the new APCu APC User Cache shared between processes?

I am planning to use the php5-apcu ubuntu package.

Is the data shared between processes? In other words, if I set a cache entry in one website load, will another website load have the cache entry available, even if it is served with another process?

How does this work for:

  • the apache2 php prefork module
  • php5 fpm with multiple workers
  • php-cli
like image 258
The Surrican Avatar asked Dec 25 '22 11:12

The Surrican


1 Answers

https://github.com/krakjoe/apcu/issues/121

The rule is that only child processes can access what their parent created; In FCGI spawned processes are not necessarily a child of their parent, they may not be actual forks. If your process manager works like conventional FCGI/CGI then you will not be able to share, if it works like FPM, and initializes PHP in a parent and forks child interpreters then you will have no problem.

Apache's prefork and PHP's FPM will share between worker processes (via the parent's memory space).

The CLI will not, as each CLI invocation is a separate process.

You might consider something like memcached or redis as an alternative.

like image 120
ceejayoz Avatar answered Jan 01 '23 22:01

ceejayoz