How do you do deployment PHP applications with enabled OpCache? My situation:

  • I have web server with PHP 7.4 and enabled OpCache.
  • Server is common virtual 4vCPU + 8GB RAM.
  • I use tool Deployer - finished with switch symlink.
  • Deployment is many times on day. Usually I deploy 5-10x times small changes.
  • Before deploy I have load 3-4.
  • After deploy I run opcache_reset (curl for http request) and load is >10. Response time is too high.

I understand how Opcache save caches to shared memory in PHP-FPM. But what is the correct solution for deployment without high-load and full availability?

  • 1
    See: serverfault.com/q/959520. It probably is not necessary to use opcache_reset. Problems may be caused by processes that switch user.
    – Gerrit
    Nov 7, 2022 at 13:40
  • I tried it. It is so better. But what if I get to limit opcache.memory_consumption? I think it will does hard reset opcache automaticaly. Is save increase configuration?
    – grogsy
    Nov 7, 2022 at 17:19
  • 1
    I think opcache does a hard reset when you reach the max wasted percentage. However when you periodically recycle your PHP processes this should not become an issue. Running processes should be recycled anyway,when you change symlinks because they can have open handles to files that are no longer valid to be used.
    – Gerrit
    Nov 8, 2022 at 9:08

1 Answer 1


Thanks for the answer and link above.

Current solution is:

  • Do not call opcache_reset after deploy.
  • Set bigger value for option opcache.memory_consumption.
  • I do opcache_reset in night as cron job.

The reason for night cron job is high CPU usage while overflow cache and OpCache automaticaly call reset cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.