nextcloud / docker

⛴ Docker image of Nextcloud
https://hub.docker.com/_/nextcloud/
GNU Affero General Public License v3.0
5.99k stars 1.82k forks source link

warning: PHP OPcache module is not properly configured: OPcache buffer is nearly full #1965

Closed meonkeys closed 1 year ago

meonkeys commented 1 year ago

I'm getting a warning on the Security & setup warnings page (/settings/admin/overview). First I've seen this one. In the past I've seen warnings about string buffers (mentioned in other issues).

Security & setup warnings

It's important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.

There are some warnings regarding your setup.

Please double check the installation guides ↗, and check for any errors or warnings in the log.

Check the security of your Nextcloud over our security scan ↗.

Screenshot from 2023-04-08 17-12-51

I'm using:

opcache.memory_consumption is how many megabytes to use in shared memory storage for OPcache. The minimum is 8 and the default is 128.

Questions:

  1. Why might OPcache be running out? Too many apps? Misbehaving apps? Misconfiguration? This is expected, and the default should be changed?
  2. The warning says opcache.memory_consumption should be increased. How much? Is there a reasonable upper bound besides just "however much system memory you can spare"? What's the best practice here?
  3. I don't notice any negative symptoms related to this warning. Should it be less severe than a warning? What kinds of symptoms might I expect to see? If the cache is rank-ordered by usefulness (say, those scripts with the most hits get to stay in the cache, those with the fewest are ejected) maybe I don't care if a few rarely used scripts aren't cached.
meonkeys commented 1 year ago

I destroyed and re-created my Nextcloud app container and the warning went away. I don't have a repro. Maybe it was running for a long time?

meonkeys commented 1 year ago

This error message popped up again, but the server seems to be working fine. No other symptoms that I can tell.

ghost commented 1 year ago

Will the problem be fixed or is there a solution for this error?

meonkeys commented 1 year ago

@R7JANV1 are you seeing this warning?

ghost commented 1 year ago

@R7JANV1 are you seeing this warning?

Yes!

meonkeys commented 1 year ago

Ok. @R7JANV1 , can you add any details about your setup, what you've tried or researched already? Also--side note--for a "me too" comment, consider adding your thumbs up to the original issue description.

The obvious solution (as rawtaz pointed out in #nextcloud on LiberaChat IRC) is to increase the value. But I have questions--I just added them to the description. I'd like to know the root cause. If the root cause is script(s) in a default nextcloud install, perhaps opcache.memory_consumption should be increased in the Dockerfile. If the root cause is an installed app, perhaps there is a problem with that app. If the root cause is related to some other resource usage (e.g. how many folders or files I have in my instance, how many apps I have installed), then maybe we can come up with some usage-specific guidance for the opcache.memory_consumption value.

https://www.saotn.org/optimize-php-opcache-configuration/ might help us figure this out.

I tried opcache_get_status(). Here's part of that output:

  ["memory_usage"]=>
  array(4) {
    ["used_memory"]=>
    int(123349000)
    ["free_memory"]=>
    int(10865416)
    ["wasted_memory"]=>
    int(3312)
    ["current_wasted_percentage"]=>
    float(0.002467632293701172)
  } 

The scripts consuming the most memory in my instance are:

  1. /var/www/html/3rdparty/scssphp/scssphp/src/Compiler.php: 793400
  2. /var/www/html/custom_apps/phonetrack/lib/Controller/PageController.php: 412072
  3. /var/www/html/apps/dav/lib/CalDAV/CalDavBackend.php: 339960

1 is probably core nc code, 3 is something I need for calendar, and 2 is for phonetrack. If phonetrack used 10x that, it might be worth disabling. Skimming the rest of the scripts, it looks like memory usage is pretty well spread out, so perhaps the warning is just due to the number of scripts period (as opposed to a particular misbehaving script or app).

ghost commented 1 year ago

I recently migrated my Nextcloud All in One instance from my Ubuntu Server to TrueNAS. There I linked a Nextcloud container and a database container using the built-in Kubernetes Docker function and migrated the data and database of the old instance to the new instance on TrueNAS.

meonkeys commented 1 year ago

Have you tried changing opcache.memory_consumption?

On my end I've decided to ignore the warning until I see some other symptom besides the warning itself.

AlterDepp commented 1 year ago

Warning still exists on NC 27.1.1

nikbpetrov commented 2 months ago

For me, it's an error - NC 28.0.8.

Interestingly - maybe due to my own ignorance - I don't have a php.ini files in /usr/local/etc but I do have /usr/local/etc/php/php.truenas.ini, which I believe is the same (although would be excited to be corrected if this is not the case).

My config is:

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=10000
opcache.revalidate_freq=1
opcache.save_comments=1

The opcache thing used to be a warning but since some time (idk when or why) it has become an error.