High memory usage - when uploading photos via FolderSync

Nextcloud version: 27.0.1
Operating system and version : Debian 11
Apache or nginx version: Nginx 1.18.0
PHP version: 8.2.8

The issue you are facing:

The php-fpm process has a very high memory usage since a few days when uploading files via Folder Sync.

Currently, the memory graph in the last 24 hours of the php-fpm service (all PHP processes combined, Nextcloud is the only PHP application) looks like this:

This is only because I’ve set pm.max_requests=50 otherwise it would eat up the swap too and then get OOM killed. My server has 32 GB of ram and half of it is already used by ZFS arc cache, PostgreSQL and other services.

I’m synchronizing my photos with FolderSync since at least a few months, and it never used that much memory. There is also no large diff, it will maybe check all these >20,000 files, but uploads are maybe like 10-50 per day.

I don’t have much knowledge of PHP, but I’ve created a core dump and with strings core.<pid> I found out that most of the memory is full of cached propfind responses.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

I don’t really know how to replicate it, but this is the steps that I’m aware of

  1. have folder sync on android setup
  2. Synchronize a folder which contains many files (at least 20k, with all subdirectories combined)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'INSTANCE_ID',
  'passwordsalt' => 'SALT',
  'secret' => 'SECRET',
  'trusted_domains' => 
  array (
    0 => 'DOMAIN',
  ),
  'datadirectory' => '/raid/nextcloud/data',
  'dbtype' => 'pgsql',
  'version' => '27.0.1.2',
  'overwrite.cli.url' => 'URL',
  'dbname' => 'DB_NAME',
  'dbhost' => '/run/postgresql',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'DB_USER',
  'dbpassword' => 'DB_PASSWORD',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'dbindex' => 0,
    'timeout' => 1.5,
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'FROM_ADDRESS',
  'mail_domain' => 'DOMAIN',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtphost' => 'SMTP_HOST',
  'mail_smtpport' => '465',
  'default_phone_region' => 'PHONE_REGION',
  'maintenance' => false,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\Image',
    1 => 'OC\\Preview\\MP3',
    2 => 'OC\\Preview\\TXT',
    3 => 'OC\\Preview\\MarkDown',
    4 => 'OC\\Preview\\OpenDocument',
    5 => 'OC\\Preview\\Krita',
    6 => 'OC\\Preview\\Movie',
  ),
  'preview_max_x' => 1024,
  'preview_max_y' => 1024,
  'preview_max_memory' => 4096,
  'preview_max_filesize_image' => 256,
  'updater.release.channel' => 'stable',
  'memories.exiftool' => '/var/www/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
  'memories.gis_type' => 2,
  'theme' => '',
  'loglevel' => 2,
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'memories.vod.path' => '/var/www/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'memories.vod.disable' => false,
  'memories.vod.vaapi' => true,
  'memories.vod.nvenc' => false,
  'memories.vod.nvenc.scale' => 'npp',
  'memories.vod.nvenc.temporal_aq' => true,
  'simpleSignUpLink.shown' => false,
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'SMTP_NAME',
  'mail_smtppassword' => 'MAIL_PW',
);


Nextcloud log and nginx log, don’t show anything related to this problem, both don’t contain any errors.
Nginx log only shows like 2-5 PROPFINDS in the timespan of 10s, but that’s it.

What else has changed in the past few days? Upgrade to v27.0.1?

What are the rest of your pm.* parameters?

Is Nextcloud the only PHP application and/or it in its FPM pool?

And, just to make sure we’re not looking in the wrong spot, does memory usage taper off if you pause FolderSync awhile?

Thanks for your reply, yes the upgrade to 27.0.1 was on the 25th of July and the issue started to occur on the 30th of July.

Yes, Nextcloud is the only php application I use.

These are the other pm.* parameters:

pm = dynamic

pm.max_children = 80

pm.start_servers = 20

pm.min_spare_servers = 20

pm.max_spare_servers = 60

pm.max_requests = 50

I’ve blocked all traffic from the FolderSync app an hour ago and it looks already better than before. As you can see in the graph of the last 12 hours, there already was a flat line for a few hours, but the spikes started again, so I’ll wait a bit more to be 100% sure, that FolderSync creates the problem.

@jtr With foldersync blocked the php-fpm process never used more than 220MB, so it must be the PROPFINDs from FolderSync that cause these memory issues.

I think 27.0.1 has some issues regarding webdav, it may not be foldwrsync itself who causes your issue, but any webdav access

Okay, thanks. Is there an issue/PR on GitHub regarding this already?

Sory for late answer, i have been unavailable for a while…