Slow speed while transfering file to and from NextCloud

Hi everyone, thanks for the attention, first post here. :grinning: :partying_face:

Issue

With the web interface, I can reach at maximum of 50 Mbps when uploading a file, and a maximum of 15 Mbps when downloading a file; but frequently the connection “drops” to 0 Mbps or get disconnected, halting the upload or denying the download all together.

A similar behaviour can be seen with the NextCloud Sync-App for Windows.

Extra infos

Here’s how the network look like:


The SuperMicro server is used as compute node and the HP server as storage node.

Here’s how the NextCloud istance look like disk-wise:


The host VM is installed on SuperMicro HDD, with an SSD cache disk and 1 Gbps connection to the NFS share.

Extra info:

  • With iperf, I tested the connection computer-to-server, and server-to-server, and all reported pretty close to 1 Gbps connection, so the problem is not on the network.
  • The download/upload speeds were monitore with nethogs
  • All the test were conducted in local LAN with 1 Gbps connection
  • The action of saving in the NFS share add some delay, but the connection is a solid ~120 MB/s between the 2 servers, so is not the (main) problem
  • I tried swapping the SuperMicro CPU for faster one but no change
  • I triend changing config:app:set files max_chunk_size from 10MB to 2GB and got an improvement, tried to disable it all together with --value 0 but got no further improvement
  • I installed both APCu and Redis, but they have given no improvement
  • PHP MPM is set to event
  • During the file transfer only one CPU core was used at 100%, while the others were idle

Specs & installed programs

SuperMicro specs
  • CPU: 2x Intel L5640 (12C/24T @ 2.2GHz)
  • RAM: 48GB DDR3 ECC
  • Main disk: 1TB Seagate 7200RPM
  • Cache Disk: 480GB Intel SSD
  • OS: Proxmox 8.2.1
HP specs
  • CPU: 2x Intel E5-2630 V2 (12C/24T @ 2.6GHz)
  • RAM: 64GB DDR3 ECC
  • Disks: 10x 500GB 7200RPM
  • OS: TrueNAS 13
NextCloud VM specs
  • CPU: 8x vCPU
  • RAM: 32GB
  • Main disk: 1x 16GB SCSi
  • Cache disk: 1x 480GB SCSi
  • Network: 1x Proxmox VirtIO
  • OS: Ubuntu 24.04 LTS server (minimazed)

The software stack installed on the VM of this NextCloud istance:

  • Nextcloud version : 29.0.2.2
  • OS version: Ubuntu 24.04 LTS server (minimazed)
  • Apache: Apache 2.4.58
  • PHP-FPM: 8.3.6
  • MariaDB: 10.11.7
  • APCu: 5.1.22
  • Redis: 5.3.7

Configs

NextCloud config.php
$CONFIG = array (
  'instanceid' => '******',
  'passwordsalt' => '******',
  'secret' => '******',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.local',
    1 => '10.101.0.10',
    2 => '******',
  ),
  'datadirectory' => '/mnt/NEXTCLOUD_DATA',
  'dbtype' => 'mysql',
  'version' => '29.0.2.2',
  'overwrite.cli.url' => 'http://nextcloud.local',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'nextcloud',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 0,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'cache_path' => '/mnt/NEXTCLOUD_CACHE',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0,
    'password' => '',
  ),
  'skeletondirectory' => '',
  'htaccess.RewriteBase' => '/',
);
fpm php.ini parameters
max_execution_time = 3600
memory_limit = 4G
post_max_size = 64G
upload_max_filesize = 64G
max_file_uploads = 20

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=1024
opcache.interned_strings_buffer=32
opcache.validate_timestamps=0
opcache.revalidate_freq=60
opcache.jit=1255
opcache.jit_buffer_size=256M
fpm www.conf parameters
pm = static
pm.max_children = 64

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
fpm 20-apcu.ini parameters
extensions=apcu.so
apc.enabled=1
apc.enable_cli=1
PHP info snippets

Last words

This is the most useful information I think I could of to share.
If you have any suggestion, to what to share more, please let me know.

It’s been a rabbit-hole of more than couple of weeks for this problem, I originally started on a Raspberry Pi 4B as compute node; after that I migrated to bare-metal Ubuntu with a noticeable improvement from the Pi, and then migrated to VM Ubuntu with no difference to bare-metal.

I hope some of you, more experienced than me, know what magic I need to do to make it more “worky” :sweat_smile: :rofl:

1 Like

Hi @FeralDucka

I’ve rarely seen such a well-organized post, and that too as a debut!
For that, I’m giving you a medal! :wink:

:medal_sports:


Your configuration shows that you have read the manual carefully.

What I miss in your configuration though, is the memchache.distributed that should be managed by Redis. Therefore, I would recommend to re-read the
→ memory caching section in the manual ← .

Then you can squeeze out some more performance if you consistently use igbinary as serializer, specially for apc, since you use apcu as memory caching backend. Therefor the "/etc/php/8.3/fpm/conf.d/20-igbinary.ini " (which is a softlink to "/etc/php/8.3/mods-available/igbinary.ini ") should look like this:

; configuration for php igbinary module
; priority=20

; Load igbinary extension
extension=igbinary.so

; Use igbinary as session serializer
session.serialize_handler=igbinary

; Enable or disable compacting of duplicate strings
; The default is On.
igbinary.compact_strings=On

; Use igbinary as serializer in APC cache (3.1.7 or later)
apc.serializer=igbinary

Additionally, I would recommend you to try if it works better if you let Redis run the memcache.local. Some users reported that it solved many problems.


I really can’t say whether these tips will solve your problem. It’s more of a gut feeling.


Much and good luck,
ernolf

1 Like

Disclaimer: I just noticed I wrote the previous post speed wrong. It’s not Mbps but MB/s. I’m extremely sorry for the confusion.

Hi, thanks for the fast response, the compliments and the good tips! :smiley:

I tried to apply what you said: setting memcache.distibuted on config.php, and enabling igbinary as described by you.

APCu parameters in PHP info

Session parameters in PHP info

Unfortunately the situation still mostly unchanged:

Now it reach peaks 75 MB/s (mostly when starting the upload), but also going to 0 MB/s from time to time. The average still 50 MB/s.

Extra
I also tried using Redis in memcache.local; that helped with the download problem (before was giving me “network error” most of the time I tried to download a file) but the upload speed became even lower. :grimacing:

You keep swapping around your units. Just want to clarify to make sure we’re understanding the numbers you’re reporting:

So a max of 50 Mbit/s (upload) and of 15 Mbit/s (download).

The action of saving in the NFS share add some delay, but the connection is a solid ~120 MB/s between the 2 servers, so is not the (main) problem

So 8 x 120 = 960 Mbit/s

Now it reach peaks 75 MB/s (mostly when starting the upload), but also going to 0 MB/s from time to time. The average still 50 MB/s.

So you’re getting 8x75 = 600 Mbit/s or 8x50 = 400 Mbit/s?

but frequently the connection “drops” to 0 Mbps or get disconnected, halting the upload or denying the download all together.
[…]
also going to 0 MB/s from time to time.

The main thing that seems weird to me is that your uploads are faster than your downloads. I would not expect that. So that may offer some clue as to where there is some bottleneck creeping in. Particularly when combined with the disconnects. Definitely a sign something is not right.

Can you elaborate on what, precisely, you experience when you say you get “disconnected”? There should be a sign somewhere (Nextcloud log, web server error log, etc.)

Were the iperf tests performed to/from the Nextcloud VM or to/from the underlying Proxmox host?

P.S. Bump your loglevel to 1 or 2. Having it at 0 (debug) might be impacting your results (though I doubt it’s the root cause).

1 Like

Sorry for the confusion, I meant:

  • NextCloud do up to ~75 MB/s in upload and ~15 MB/s in download (even tho the average of upload was ~50 MB/s yesterday and 25 MB/s today, dunno why)
  • The NFS communication reach up to ~120 MB/s (960 Mbps), which mean is not the bottleneck
  • All the Iperf test (workstation to nextcloud, workstation to truenas, nextcloud to truenas) reported around 1 Gbps connection
iperf to the Ubuntu --> workstation

iperf to the Ubuntu --> TrueNAS

You’re totally right: there’s something strange; but I don’t know what yet :sweat_smile:

Here some upload screen I just did:

upload by SyncApp

syncapp_3

nethogs_3

I only got 2 MB/s in upload while syncing today :melting_face:

download via browser

Sometime it fail all together, other times it download but never goes more than 15 MB/s

From the Ubuntu VM, in which NextCloud is running in. I think, if the VM give good result, will be the same for Proxmox. :grimacing:

As seen in one of the screenshot, sometimes it says “Network Error” in the web browser, or the SyncApp says “Disconnected” while syncing files (I could not reproduce the case at the moment, it doesn’t do it all the time).

I tried to see in the logs now, but there nothing about the failed downloads.

In the past I, sometime, got: !!! Path 'uploads/web-file-upload' is not accessible or present !!! or Could not open file in the nextcloud.log during upload, I fixed it with setting cache_path to the cache SSD

Extra info
I tried changing memcache.local again between Redis and APCu, without getting any difference in behaviour

Extra info 2
I just discovered one of the bottlenecks was the Http2 windows size in Apache2. I set it at 10MB in apache.conf with H2WindowSize 10485760.
Now the upload speed stay between 50MB/s and 75MB/s again.

Sorry for the late response. :sweat_smile: