Issue

OPcache speeds up performance in two ways.  The first is by caching precompiled byte code.  The second is by optimizing the OPcode prior to writing to cache.  PHP applications showing unexpected results can sometimes be caused by an optimization.  This happens rarely, but it can happen.  One way to check if this is the problem is to disable optimization.

Environment

Any version of Zend Server.

Resolution

The default value for the Zend OPcache directive opcache.optimization_level is:

0xffffffff

This hex value represents a bitmask flagging all optimizations to run.

Please try setting this value to:

0

That is to say, just use the decimal numeral '0', so that the OPcache optimizations do not run.  This can improve stability for some applications.  Byte code caching will still take place.

To set the directive, please go into the Zend Server UI, and go to Administration -> Components (version 2019 or earlier) or Administration -> Extensions (version 2020 or later).  For later versions of Zend Server, please make sure Advance View is set on.  The Advance View switch is just above the top of the table, towards the right.  Find Zend OPcache on the list of components, and give it one mouse click to expand the directives.  On the list of directives, find opcache.optimization_level and set the value to 0 (the decimal digit zero).  You can also change the opcache.consistency_checks directive to 1 on this display.  Once you change the directive(s), the Save button on the top left of the table becomes enabled.  Click the Save button, and when prompted restart Zend Server.  The restart takes your web site down for a short while, so please schedule this operation for a time when this would be acceptable.


Consistency checks may also increase stability.

Consistency checking verifies the cache checksum.  This can improve stability in some situations.  To enable it, set the opcache.consistency_checks directive to 1.
  • No labels