My website is running on PHP 5.5 with FastCGI (mod_fcgi
). I'm aware that other opcache types (like APC) doesn't work well as memory is not shared between php-cgi processes (here).
I'm using PHP 5.5 built-in OPcache. Is the memory shared between processes or this is exactly the same problem of APC/Xcache with mod_fcgi
?
Is there any way to test it?
OPcache is a caching engine built into PHP. When enabled, it dramatically increases the performance of websites that utilize PHP. From php.net: OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
OPcache can only be compiled as a shared extension. If you have disabled the building of default extensions with --disable-all, you must compile PHP with the --enable-opcache option for OPcache to be available. Once compiled, you can use the zend_extension configuration directive to load the OPcache extension into PHP.
To clear the Opcache on CLI, just restart your PHP command. It's usually as simple as CTRL+C to abort the command and start it again.
I have never understood why this was even entertained as a possibility, it is not a realistic possibility:
Both APC and Opcache have several forms of shared memory, their defaults and the most suitable kind is mmap'd memory, but for all kinds of strange reasons they need to support inferior kinds, none of these inferior kinds leave a possibility (even an unrealistic one) for this to work.
When it comes to mmap...
If you do not provide a file mask APC uses anonymous shared mapping, you cannot share this across distinct process boundaries, not possible.
If you do provide a file mask, APC uses unsynchronized shared mapping, it doesn't make sense to try and share that across distinct process boundaries since it will nearly always contain a corrupted shadow of the mapped memory, that's the nature of unsynchronized.
Doesn't provide you with any of the non-options that APC tried to provide, all mapping is done anonymously.
Use a sane webserver such as nginx/lighthttpd, and use fpm
, included with PHP.
FPM's process model allows the child processes it forks to have a common cache, problem solved, applicable to both APC and Opcache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With