nextcloud / docker

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

warning: The OPcache buffer is nearly full #2184

Open adripo opened 5 months ago

adripo commented 5 months ago

I am having a warning that indicates that opcache memory is almost full. I checked and this issue was already raised in some closed issues: https://github.com/nextcloud/docker/issues/1926

And I also checked the values used in All-in-one solution to solve similar issues.

This PR was successfully merged and I this it should be applied to the docker version too: https://github.com/nextcloud/all-in-one/pull/2762/

Impacted files: https://github.com/nextcloud/docker/blob/6151f60208d08fe7dbd28b6b00a3bcd1e626e7ff/Dockerfile-alpine.template#L88 https://github.com/nextcloud/docker/blob/6151f60208d08fe7dbd28b6b00a3bcd1e626e7ff/Dockerfile-debian.template#L100

I would also apply the related config changes from all-in one:

opcache.interned_strings_buffer=64
opcache.memory_consumption=256
opcache.jit_buffer_size=8M
tzerber commented 3 months ago

Jumping on this bandwagon. On a relatively busy instance I need to use these values to get rid of the warning. Not a PHP expert at all, but I was increasing them until the error went away, using whatever PHP was complaining about until i get it green. NC version 29, 10 active users, NC used mostly via browser for office work/emails/deck/ and additionally around 100GB traffic between users / day.

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=12000
opcache.memory_consumption=512
opcache.save_comments=1
opcache.revalidate_freq=60
opcache.jit = 1255
opcache.jit_buffer_size = 256M
tarbib commented 3 months ago

Hello @adripo @tzerber I have the same issue. I actually struggle to locate the file php.ini within the Nextcloud container. Any pointers? Thanks !

tzerber commented 3 months ago

Hello @adripo @tzerber I have the same issue. I actually struggle to locate the file php.ini within the Nextcloud container. Any pointers? Thanks !

Depends if you're using docker or not. Usually phpinfo() can give you hints on ini location

tarbib commented 3 months ago

Depends if you're using docker or not. Usually phpinfo() can give you hints on ini location

I use Docker indeed the image linked to this repo https://hub.docker.com/_/nextcloud/

tzerber commented 3 months ago

Depends if you're using docker or not. Usually phpinfo() can give you hints on ini location

I use Docker indeed the image linked to this repo https://hub.docker.com/_/nextcloud/

For opcache I use the following mounted local ini in all containers :

volumes:
      - nextcloud:/var/www/html
      - ./opcache-recommed.ini:/usr/local/etc/php/conf.d/opcache-recommended.ini

The actual conf used by the container is this one /usr/local/etc/php-fpm.conf and it loads everything from /usr/local/etc/php/conf.d/*conf too. Both those paths are !! Inside !! the container, not on your host!

MichaIng commented 2 months ago

@tzerber

opcache.jit_buffer_size = 256M

Try to use opcache.jit_buffer_size = 2M. I never saw a Nextcloud instance which uses more than 1 MiB of this particular sub-buffer. And since it occupies from opcache.memory_consumption, it is likely the only reason why you needed to raise the latter, while otherwise the default 128M would have been sufficient, in combination with opcache.interned_strings_buffer=32 max, often 8 or 16, depending on used apps.

adripo commented 1 month ago

I just upgraded to v29.0.3 and I am getting this error when executing occ setupchecks:

✗ PHP opcache: The PHP OPcache module is not properly configured. OPcache is not working as it should, opcache_get_status() returns false, please check configuration.
The maximum number of OPcache keys is nearly exceeded. To assure that all scripts can be kept in the cache, it is recommended to apply "opcache.max_accelerated_files" to your PHP configuration with a value higher than "10000".
The OPcache buffer is nearly full. To assure that all scripts can be hold in cache, it is recommended to apply "opcache.memory_consumption" to your PHP configuration with a value higher than "128"..
MichaIng commented 1 month ago

I didn't know that this CLI command exists. Since OPcache is intentionally disabled for CLI calls, all those tests must be skipped. Or at least it must first be checked whether opcache.enable_cli is enabled. Probably not a bad idea, so CI tests can be added. Of course, if opcache.enable_cli is disabled (reasonable default and production value), it must not return any error, also not in CLI. But if it is enabled, we can run the other checks as well, for debugging and development.

@adripo Could you please open a new issue about this (since it is unrelated to the one we are currently posting to) to the Nextcloud server repository? Link or quote what I wrote above. I'll try to implement this, when I find time, and in case no one else is faster.