Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Last active September 8, 2017 05:59
Show Gist options
  • Save molotovbliss/a95736ef12ef06d1a9052a1930a610b3 to your computer and use it in GitHub Desktop.
Save molotovbliss/a95736ef12ef06d1a9052a1930a610b3 to your computer and use it in GitHub Desktop.
Optimal PHP OPCache for Magento 2
# Since Magento 2 has even 2x the stack traces, means more OP code to cache in memory and avoid
# disk I/O scans with autoloaders without classmapping.
### TOOL
# Identify number of possible PHP files to consider
# view/manage OPcache in a single PHP file
`wget https://github.com/rlerdorf/opcache-status/raw/master/opcache.php`
# estimate number of max files to run at root of magento
`find . -type f -print | xargs grep "<?php" | wc -l`
# output returned from the command above, should set max_accelerated_files
# with padding (example: 60k php files found, +5-10k for a buffer)
# note: 65406
`opcache.max_accelerated_files=65406`
*Production ini*
```
[opcache]
opcache.validate_timestamps=0
opcache.revalidate_freq=0
opcache.max_accelerated_files=65536
opcache.memory_consumption=192
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1
```
*Development/Local ini*
```
[opcache]
opcache.validate_timestamps=1
opcache.max_accelerated_files=65536
opcache.memory_consumption=192
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1
```
* https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
* https://magento.stackexchange.com/questions/95058/opcache-recommended-configuration-for-magento2
* http://devdocs.magento.com/guides/v2.1/install-gde/prereq/php-settings.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment