7

So, we have a Laravel 5.1 based project we want to release soon, but we're noticing poor performance, and we're trying to optimize the server setup.

As listed in the title, we're deploying this on a CentOS 6.7 server, with Nginx 1.8.1 and PHP 7 with PHP-FPM. Since CentOS 6.7's repositories do not offer PHP 7, we're using IUS' replacement packages.

One of the things we noticed that might be causing poor performance is the fact that Zend Opcache, despite being enabled and working (we have a good hit rate), does not seem to be caching all of the files in our project. We're using opcache-gui to help visualize the contents of the cache and, while many of the project's files are there (including files from third party libraries), most are missing, including our main controller and many of the supporting classes. In fact, when we disable Opcache, the response times remain virtually the same. The opcache blacklist is currently empty, so that's not the reason why they're not being included.

We've attempted to forcefully cache the missing files using opcache_compile_file(), and while the files do get compiled and cached, they never get any hits.

It was my understanding that Opcache would cache all of the files being executed, but that doesn't seem to be what's happening here. I've looked at the opcache settings, but could not find one that would obviously influence this kind of behavior, apart from the blacklist.

Is there anything else that I'm missing? Any other criteria that PHP would rely on when deciding on what to cache or not?

Any help on the matter would be appreciated!

santista
  • 71
  • 1
  • Another thing I thought I'd mention, I am aware that there is a limit on the number of accelerated files opcache is capable of handling, which can be adjusted in the opcache.ini file setting `opcache.max_accelerated_files`. We have that currently set to 8000, which should be more than enough to cover all of our files, however, only about 163 end up being cached. – santista May 20 '16 at 20:26
  • Memory consumption also does not appear to be an issue, as we have allocated 128MB via `opcache.memory_consumption`, opcache-gui shows only 23.1MB is being used. – santista May 20 '16 at 20:34
  • Any resolution to this one? I am having the same problem. – anon May 31 '16 at 21:57
  • Out of curiosity. What happens if you set `opcache.validate_timestamps=0` ? – Danila Vershinin Jul 04 '16 at 21:23

1 Answers1

0

Can you check the value of opcache.max_file_size? Maybe that's your issue, as compiled files are larger than original file.

Can you test the files you don't see in opcache-gui with http://php.net/opcache-is-script-cached?

Also, as a test, can you try to force the compile? Use http://php.net/opcache-compile-file for this matter. It's just to see if there's a true and if it can compile it in the first place.

Yvan
  • 2,539
  • 26
  • 28