Score:-1

Deployment PHP with OpCache

in flag

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?

Gerrit avatar
cn flag
See: https://serverfault.com/q/959520. It probably is not necessary to use opcache_reset. Problems may be caused by processes that switch user.
grogsy avatar
in flag
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?
Gerrit avatar
cn flag
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.
Score:0
in flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.