Relatively slow uploads and downloads on Nextcloud over YunoHost

Nextcloud version (eg, 20.0.5): 25.0.3
Operating system and version (eg, Ubuntu 20.04): Debian Stable
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.18.0
PHP version (eg, 7.4): 8.1

The issue you are facing:
My current setup is only able to upload and download at an extremely limited speed (under 3 MB/s). Things I’ve tried without success:

  • Optimizing the MySQL database using MySQLTuner
  • Using both the default settings for PHP-FPM and increasing the amount of children threads
  • Disabling most of the Nextcloud applications
  • Testing if the storage device itself is slow - doesn’t seem to be the case, as downloading via Rsync is at least 3 times faster.

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

Steps to replicate it:

  1. Install Nextcloud on a Debian Stable server through YunoHost
  2. Upload a large file. Notice that the upload speed is capped to under 3 MB/s.
  3. Download the large file via Rsync. Notice that the upload speed is much faster, at minimum 9 MB/s.

The output of your Nextcloud log in Admin > Logging:

{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php","Line":208,"message":"Could not classify incoming message importance: Deserialized estimator has an unknown type Rubix\\ML\\Encoding","exception":{},"CustomMessage":"Could not classify incoming message importance: Deserialized estimator has an unknown type Rubix\\ML\\Encoding"}}
{"reqId":"Lt2eslDfK8q95TN87h8O","level":3,"time":"2023-01-26T17:16:21+00:00","remoteAddr":"","user":"--","app":"mail","method":"","url":"--","message":"Cron importance classifier training failed: Rubix\\ML\\Persisters\\Filesystem::save(): Argument #1 ($encoding) must be of type Rubix\\ML\\Encoding, Rubix\\ML\\Classifiers\\GaussianNB given, called in /var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php on line 118","userAgent":"--","version":"25.0.3.2","exception":{"Exception":"TypeError","Message":"Rubix\\ML\\Persisters\\Filesystem::save(): Argument #1 ($encoding) must be of type Rubix\\ML\\Encoding, Rubix\\ML\\Classifiers\\GaussianNB given, called in /var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php on line 118","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php","line":118,"function":"save","class":"Rubix\\ML\\Persisters\\Filesystem","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Classification/ImportanceClassifier.php","line":220,"function":"persist","class":"OCA\\Mail\\Service\\Classification\\PersistenceService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/TrainImportanceClassifierJob.php","line":97,"function":"train","class":"OCA\\Mail\\Service\\Classification\\ImportanceClassifier","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/recognize/vendor/rubix/ml/src/Persisters/Filesystem.php","Line":78,"message":"Cron importance classifier training failed: Rubix\\ML\\Persisters\\Filesystem::save(): Argument #1 ($encoding) must be of type Rubix\\ML\\Encoding, Rubix\\ML\\Classifiers\\GaussianNB given, called in /var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php on line 118","exception":{},"CustomMessage":"Cron importance classifier training failed: Rubix\\ML\\Persisters\\Filesystem::save(): Argument #1 ($encoding) must be of type Rubix\\ML\\Encoding, Rubix\\ML\\Classifiers\\GaussianNB given, called in /var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php on line 118"}}
{"reqId":"ZuHM8qx9x5yEbcuT2JUc","level":3,"time":"2023-01-26T18:16:25+00:00","remoteAddr":"","user":"--","app":"mail","method":"","url":"--","message":"Could not classify incoming message importance: Deserialized estimator has an unknown type Rubix\\ML\\Encoding","userAgent":"--","version":"25.0.3.2","exception":{"Exception":"OCA\\Mail\\Exception\\ServiceException","Message":"Deserialized estimator has an unknown type Rubix\\ML\\Encoding","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php","line":162,"function":"load","class":"OCA\\Mail\\Service\\Classification\\PersistenceService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Classification/ImportanceClassifier.php","line":300,"function":"loadLatest","class":"OCA\\Mail\\Service\\Classification\\PersistenceService","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Listener/NewMessageClassificationListener.php","line":118,"function":"classifyImportance","class":"OCA\\Mail\\Service\\Classification\\ImportanceClassifier","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":87,"function":"handle","class":"OCA\\Mail\\Listener\\NewMessageClassificationListener","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":88,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":401,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":235,"function":"runPartialSync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":136,"function":"sync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":110,"function":"syncAccount","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/lib/Service/Classification/PersistenceService.php","Line":208,"message":"Could not classify incoming message importance: Deserialized estimator has an unknown type Rubix\\ML\\Encoding","exception":{},"CustomMessage":"Could not classify incoming message importance: Deserialized estimator has an unknown type Rubix\\ML\\Encoding"}}

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

<?php                                                                                                                                              [14/2217]$CONFIG = array (
  'datadirectory' => '/home/yunohost.app/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'installed' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'updatechecker' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'integrity.check.disabled' => true,
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => '6379',
    'timeout' => '0.0',
    'password' => '',
  ),
  'hashing_default_password' => true,
  'localstorage.allowsymlinks' => true,
  'simpleSignUpLink.shown' => false,
  'maintenance' => false,
  'trusted_proxies' =>
  array (
    0 => '127.0.0.1',
    1 => '::1',
  ),
  'default_phone_region' => 'CR',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

tail /var/log/nginx/cloud.azkware.net-error.log
2023/01/26 12:37:17 [error] 3713810#3713810: *1504720 connect() failed (111: Connection refused) while connecting to upstream, client: 186.26.118.150, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:37:56 [error] 3713810#3713810: *1504869 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:38:45 [error] 3713810#3713810: *1504869 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:39:35 [error] 3713810#3713810: *1504869 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:40:28 [error] 3713810#3713810: *1504869 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:41:22 [error] 3713810#3713810: *1504869 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:42:20 [error] 3713810#3713810: *1505667 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:43:19 [error] 3713810#3713810: *1505667 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:44:20 [error] 3713810#3713810: *1505667 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"
2023/01/26 12:45:22 [error] 3713810#3713810: *1506164 connect() failed (111: Connection refused) while connecting to upstream, client: 136.226.0.112, server: cloud.azkware.net, request: "GET /push/ws HTTP/1.1", upstream: "http://127.0.0.1:7867/ws", host: "cloud.azkware.net"