Dual core, 4 gig ram not enough for single user server!? how to tune?

Nextcloud version (eg, 20.0.5): 22.2 (nextcloud:apache (offical docker image)
Operating system and version (eg, Ubuntu 20.04): Arch
Apache or nginx version (eg, Apache 2.4.25): nextcloud:apache (offical docker image)
PHP version (eg, 7.4): nextcloud:apache (offical docker image)

The issue you are facing:

After uploading photos, navigating to a a share causes the server to consume all ram (4 gigs) all swap(512megs) and OOM.
Hitting F5 shows that a few preview images were created before the crash… then consumes all ram and crashes again.

I can work around this by hitting F5 every few minutes, untill all previews on the first page are loaded… then VERY slowly scrolling down, one line at a time, allowing those previews to generate, before scrolling further.

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

Steps to replicate it:

  1. Upload a folder containing many photos (50 or so)
  2. Nagivate to folder in a web browser.
  3. Server with 4 gigs of ram OOM’s

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'instanceid' => 'SOME_INSTANCE_ID',
  'passwordsalt' => 'SOME_SALT',
  'secret' => 'SOME_SECRET',
  'trusted_domains' =>
  array (
    0 => '127.0.0.1:8080',
    1 => 'MY.DOMA.IN',
    2 => 'OTHER.DOMA.IN',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '22.2.0.2',
  'overwrite.cli.url' => 'http://127.0.0.1:8080',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '########',
  'installed' => true,
);

I only have a dual core server… But it seeems that the server is spawning many many tasks to generate image previews.

my CPU usage hits 100%, and all ram is exhaused.
A slow image preview generation is preferable to a crash.
Can I configure nextcloud to only spawn 1 or 2 image preview generation threads ?

How much ram is recommended for a single instance server, with just a few gigabytes of photos?

My last server, ran fine with just 1 core, and 1 gig of ram…
But i uploaded photos one at a time over a few years.

Uploading a hand-full of photos in one go (50) killed it.

THANKYOU for any tips / hints.

I see what you mean. The issue looks like it comes down to the file requests made by the browser. It calls for the image thumbnails on the fly, which the server subsequently generates.

This is the documentation on the feature. Looks like you can decrease the jpeg quality, which should speed it up.

If only pictures are the problem you can use Preview Generator or configure preview settings. There you also find the possibilty to deactivate preview.