Out of memory when generating previews

Nextcloud version (eg, 20.0.5): 23.0.1-1
Operating system and version (eg, Ubuntu 20.04): latest
Apache or nginx version: nginx 1.20.2-1
PHP version: 8.1.3-1

The issue you are facing:

When opening a directory with a lot of images in my browser, nextcloud will fire lots of php-fpm workers to generate preview images. This slows down the server making viewing the images very slow. But even worse, after a while all the memory of my server is filled up, making systemd-oomd kill the php-fpm process. Disabling image previews seems to avoid this problem.

My server has 2GB of ram, so that’s way more than the minimum specs of 512mb. I there anything I can do to improve the memory usage and performance?

I’m using APCu as memory caching. I tried tweaking the number of servers in php-fpm, but even with the current numbers it runs out of memory.

My php-fpm configuration:

[nextcloud]
user = nextcloud
group = nextcloud
listen = /run/nextcloud/nextcloud.sock
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
 
; should be accessible by your web server
listen.owner = http
listen.group = http
 
pm = dynamic
pm.max_children = 60
pm.start_servers = 6
pm.min_spare_servers = 3
pm.max_spare_servers = 9

Hi @TheStroyer

Just a guess… But I would try installing PHP 8.0 or 7.4. Nextcloud doesn’t support PHP 8.1 yet.

And you should avoid using interim releases of Ubuntu like 21.10. Try to stick with the LTS releases if possible. It’s easier to get newer packages for things like PHP on an LTS release, if needed, than the other way around…