APC -> APCu / OPCache, performance poor

后端 未结 3 563
青春惊慌失措
青春惊慌失措 2020-12-23 20:54

I have an m3.xlarge EC2 instance that I updated to PHP 5.5.11 today.

With this update, it overwrote php55-pecl-apc with

相关标签:
3条回答
  • 2020-12-23 21:35

    Right now you are checking every file on every request for changes, which probably isn't what you want on a production system.

    I usually just disable it (remember to restart the web server after making changes):

    opcache.validate_timestamps=0
    

    Alternatively, you can try setting the frequency to something other than 0 and keep it enabled:

    opcache.validate_timestamps=1  
    opcache.revalidate_freq=300
    

    This should theoretically only check for changes every 5 minutes.

    0 讨论(0)
  • 2020-12-23 21:35

    You also have

    opcache.consistency_checks=1
    

    Which according to the docs says will slow down performance. Turn that off.

    opcache.consistency_checks integer

    If non-zero, OPcache will verify the cache checksum every N requests, where N is the value of this configuration directive. This should only be enabled when debugging, as it will impair performance.

    0 讨论(0)
  • 2020-12-23 21:36

    From the RFC that was responsible for making OPCache integrated into PHP:

    APC can reclaim memory of old invalidated scripts. APC uses a memory manager and can reclaim memory associated with a script that is no longer in use; Optimizer+ works differently, and marks such memory as ‘dirty’, but never actually reclaims it. Once the dirty percentage climbs above a configurable threshold - Optimizer+ restarts itself. Note that this behavior has both stability advantages and disadvantages.

    My guess is that you are hitting the threshold that triggers the opcode cache restart.

    Reference: https://wiki.php.net/rfc/optimizerplus#advantages_of_apc_over_optimizer

    0 讨论(0)
提交回复
热议问题