Search code examples
phpcachingcloudflare

Understanding OPCache behavior


Even tho the website is behind CloudFlare CDN, we decided to use OPCache to reduce the load on server as there are a maximum (peak) of ~400 active users per second (most of the time it's 50-100 u/s).

But most pages have some different data for each user, for example user's dashboard overview, most of the data is same but it has some different numbers for each user that needs to be up to date.

My Questions are:

  1. Is it wise to use OPCache for such a website?
  2. How will it handle pages with unique queries? will it take more RAM (caching multiple pages for each user) than running without OPCache?
  3. Will it affect performance on pages such as Signup/Login etc?
  4. I read that all PHP applications should use OPCache, is that correct?

P.S. The website is running on PHP 7.3.4


Solution

    1. Yes it will gain performance improvement
    2. If your RAM usage increased and you're concerned with it, you can fine tune memory consumption via opcache.memory_consumption
    3. Affect meaning they will be faster
    4. Yes, there really is no reason to not use OPCache other than edge cases (e.g., when your app's source code changes at a very fast rate or testing).

    TLDR: Production code should always have OPCached enabled.