0% using OPcache and PHP-FPM / Nginx

I am trying to get PHP 5.5 OPcache to work on an Nginx / PHP-FPM installation running on Ubuntu 14.04 in Vagrant.

I have a directory /etc/php5/mods-available/opcache.ini

configured like this:

zend_extension=opcache.so

opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=50000

      

Startup php -v

and phpinfo()

shows OPcache is enabled and opcache-status is loaded and opcache-gui shows the same.

In the OPcache GUI I can see that files are being cached and I have also confirmed this by setting OPcache to enter verbose mode. The problem is ... they never hit!

I ran ApacheBench to hammer the application and no hit was recorded - 0 hits and 103 misses. I even tested a file hello_world.php

that just executes echo 'Hello, world!';

and it also logs as "miss".

Anyone can figure out what might be wrong?

Update: I was able to get a reproducible hit log case. If right after starting service php5-fpm restart

I run ApacheBench with 100 concurrent connections, the cache hits> 75%. From now on, every "normal" update is also recorded as a hit.

However, if I restart php-fpm and my initial requests are "normal" (eg only from my web browser) and then I run ApacheBench with 100 concurrent connections - they all miss ...

He, like the initial requests, must clog the server in order for the hits from now on to be ... really strange! I am guessing it might have something to do with php-fpm spawning processes, but I am actually new to the field, so if this gives anyone a hint - please help!

+3


source to share





All Articles