Slow loading of webpage during browsing folders and files

Nextcloud version : 19.0.4
Operating system and version : CentOS Linux 8
Nginx version : 1.14.1
PHP version : 7.4.10
DB mariadb version : * 10.3.17*

Current config:
Virtualized server on ESXi host
VM resources:
CPU: 16 cores Xeon e5-2680v2
RAM: 20GB DDR3 1333MHz
Disks: RAID 5 (4x SSD Samsung PRO 860 1TB)

Nextcloud have local storage with 10000 files in 1 folder (5000 files are empty, other 5000 files are 5MB size), also previously I’ve tested config with external storage via SMB share with about 10000 folders in parent folder.

Main problem is slow refreshing of website when I open folder with 10K files/folders. Every refresh of site leads to slow displaying of content. It loading 6-7 seconds. This problem is observed on both local and external storage.

Other important problem - broken search in folders with many files. In test folder with 10000 files search stops site and page not responding.

Main question - How do speed up loading of webpages with such content (10K files)?

Tried to tune nginx, php-fpm, DB, memory-caching, but haven’t seen difference. Also tried to switch nginx to apache, install other versions of Nextcloud (10 to 20), disable unused Nexcloud apps.

Additional Information

Other symptoms:
In moment when folder is opening one CPU core loads 100% by process php-fpm pool www.
Current /etc/php-fpm.d/www.conf :

[www]
user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 220
pm.start_servers = 24
pm.min_spare_servers = 12
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
request_slowlog_timeout = 3
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache
php_value[opcache.file_cache]  = /var/lib/php/opcache

Current /var/www/nextcloud/config/config.php:

<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.***.***',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => 'http://nextcloud.***.***',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '***',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'log_type' => 'file',
  'log_file' => '/var/log/nextcloud.log',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'skeletondirectory' => '/var/www/nextcloud/data/donotdeletme',
  'updater.release.channel' => 'stable',
  'onlyoffice' =>
  array (
    'verify_peer_off' => true,
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
  ),
  'enable_previews' => false,
  'auth.bruteforce.protection.enabled' => false,
  'simpleSignUpLink.shown' => false,

Thank you in advance for your response!

Sorry. No real idea. Maybe to much or less RAM and/or swapping.

Perhaps you can change temporally to

pm = static

for testing some static parameters and the behavior. Read

https://tideways.com/profiler/blog/an-introduction-to-php-fpm-tuning

Normally it is sorted in subfolder.

old:

00000
00001
..
99999

new

00/000
00/011
...
99/999

I’ve tuned Process Manager to

pm = static
pm.max_children = 150
pm.start_servers = 64
pm.min_spare_servers = 32
pm.max_spare_servers = 64

according to article you’ve sent, loading of page is 5-6 sec now.

Actually I search for solution without changing hierarchy of existing folders. Is it possible to cache view of folder on client side? Like first slow (5-6 sec) loading and then open this folder without new loading (refreshing).

For browser you can use Mozilla Firefox and F12 to analyse the network. Perhaps you find the problem. But i think not.

I think nextcloud is not optimised for large folders. Normally nextcloud must only load the folders / folder names you can see and not all folders like scrolling through Google Images https://www.google.de/search?q=nextcloud&source=lnms&tbm=isch or Twitter https://twitter.com/search?q=nextcloud&src=typed_query&f=live

I think i have got less problems with picture folders but only with 100 to 200 pictures.
If it is a problem perhaps you can open an issue at https://github.com/nextcloud/server/issues

Thanks for advice, created an issue


I’ll be waiting for advices and solutions.