Zend OPcache
One major downside of PHP is that it loads and parses the PHP script on every request. Written in plain text, the PHP code is first compiled to opcodes, then the opcodes are executed. While this performance impact might not be noticeable with small applications that have one or few scripts in total, it makes a big difference with larger platforms, such as Magento, Drupal, and so on.
Starting from PHP 5.5, there is an out-of-the-box solution to this problem. The Zend OPcache extension addresses the repetitive compilation issue by storing the compiled opcodes in shared memory (RAM). Turning it on or off is simply a matter of changing the configuration directive.
There are quite a few configuration directives, a few of which will get us started:
opcache.enable
: This defaults to 1 and is changeable viaPHP_INI_ALL
.opcache.enable_cli
: This defaults to 0 and is changeable viaPHP_INI_SYSTEM
.opcache.memory_consumption
: This defaults to 64 and is changeable viaPHP_INI_SYSTEM
, which defines...