Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fine-Tune Your Opcache Configuration to Avoid Caching Suprises

Fine-Tune Your Opcache Configuration to Avoid Caching Suprises

Benjamin Eberlei

March 14, 2023
Tweet

More Decks by Benjamin Eberlei

Other Decks in Programming

Transcript

  1. RELEVANT PHP.INI CONFIG ▪ opcache.memory_consumption defaults to 64 (MB) for

    caching all compiled scripts. ▪ opcache.max_accelerated_files defaults to 2000 cacheable files ▪ opcache.max_wasted_percentage defaults to 5% 2
  2. What happens? 1. Opcache attempts to restart when limits are

    reached 2. If the waste percentage is not reached, no restart is performed. 3. All scripts that are not in Opcache at that time will always stay uncached. 4
  3. How to monitor? opcache_get_status(true) returns the relevant metrics. 1. cache_full

    and opcache hit rate below 99%? Increase memory usage 2. cache_full and num_cached_keys equals max_cached_keys. Increase accelerated files. 5