Skip to content

Instantly share code, notes, and snippets.

@mrsombre
Created March 16, 2015 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsombre/c2a2c9d0335bd36ecbbc to your computer and use it in GitHub Desktop.
Save mrsombre/c2a2c9d0335bd36ecbbc to your computer and use it in GitHub Desktop.
Заметки о PHP
http://jpauli.github.io/2015/03/05/opcache.html
Configuring OPCache#
If you use a framework based application, like a Symfony2 based application, I strongly suggest :
you turn off revalidation mechanism on production (turn opcache.validate_timestamps to 0)
you deploy using a full new runtime of your scripts, this is the case with Symfony2 applications
you size correctly your buffers
opcache.memory_consumption, the most important
opcache.interned_strings_buffer , monitor your usage, and size accordingly, take care if you tell OPCache to save comments, which you will likely do if you use PHP "annotations" (opcache.save_comments = 1), those are strings, big strings, that will eat your interned strings buffer
opcache.max_accelerated_files , numbers of keys to preallocate, once more : monitor and size accordingly
You turn off opcache.opcache.revalidate_path and opcache.use_cwd. That will save some key space
You turn on opcache.enable_file_override , this will accelerate the autoloader
You fill-in opcache.blacklist_filename list with the script names you are likely to generate during runtime; shouldn't be too many of them anyway
With those settings, your memory should never get wasted, then opcache.max_wasted_percentage is not very useful in this case. With those settings, you'll need to turn off your main FPM instance when deploying. You may play with several FPM pools to prevent service downtime, like explained earlier.
That should be enough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment