Nextcloud 22 in docker: too much CPU resources was occupied

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version : fpm-alpine 22.01(docker)
Operating system and version (eg, Ubuntu 20.04): alpine(docker background)
Apache or nginx version (eg, Apache 2.4.25): Caddy 2
PHP version (eg, 7.4): default in docker

The issue you are facing:

As the title suggests, my nextcloud is constantly consuming my cpu resources fiercely(For most of the time 200%-400% in docker stats). That should not be a problem if it is normal. But the real trouble it causes is a very slow frontend of my nextcloud instance. In comparison, I run a Synology NAS in my home, I use frp to expose it on this server. The loading time of Nextcloud (about 20-30 sec) , which is up and running on this server, is significantly higher than my synology (5 sec) that is passed through to here.

Another problem that I experienced simultaneously is that Nextcloud forget my login on this browser very often, and most of the time it refused my password when I entered it for the first time. I don’t know if it is going to help to find the cultprint.

image

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

Steps to replicate it:

  1. Just installed the nextcloud docker instant and use, don’t know how specific the problem was created. But I know it can be very fast.

The output of your Nextcloud log in Admin > Logging: The Log is too long, so I paste some representative logs

[index] Error: Argument 1 passed to OC\Group\Manager::getUserIdGroupIds() must be of the type string, null given, called in /var/www/html/lib/private/Group/Manager.php on line 316

GET /apps/deck/
from XXX by XXX at 2021-08-07T12:39:03+00:00

[PHP] Error: Cannot modify header information - headers already sent by (output started at /var/www/html/3rdparty/sabre/http/lib/Sapi.php:132) at /var/www/html/apps/dav/lib/Connector/Sabre/File.php#693

PUT /remote.php/dav/files/User/Notes/Day%20Planners/Day%20Planner-20210807.md
from xx by xxx at 2021-08-07T12:03:20+00:00

[no app in context] Error: Expected filesize of 2670 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 0 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

PUT /remote.php/dav/files/User/Notes/Day%20Planners/Day%20Planner-20210807.md
from 000.000.000.000 by User at 2021-08-07T12:03:20+00:00

[no app in context] Error: An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb3_general_ci' is not valid for CHARACTER SET 'utf8mb4'

GET /ocs/v2.php/cloud/users/details?offset=0&limit=25&search=
from 000.000.000.000 by User at 2021-08-07T10:09:29+00:00

[core] Warning: Login failed: 'User' (Remote IP: '000.000.000.000')

POST /login/confirm
from 000.000.000.000 by User at 2021-08-07T06:55:06+00:00

[webdav] Fatal: OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.

PROPFIND /remote.php/webdav/Linux_config/autokey
from 000.000.000.000 at 2021-08-07T05:34:42+00:00

[no app in context] Error: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.

PROPFIND /remote.php/webdav/Linux_config/autokey
from 000.000.000.000 at 2021-08-07T05:34:42+00:00

[caldav] Fatal: OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.

REPORT /remote.php/caldav/calendars/User/inbox-1/
from 000.000.000.000 by User at 2021-08-07T05:34:41+00:00

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',
  '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,
    ),
  ),
  'instanceid' => 'ocorm2y3imb5',
  'passwordsalt' => 'UHO9j+',
  'secret' => '+/',
  'trusted_domains' => 
  array (
    0 => '..',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '22.0.0.11',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => false,
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => '..',
  'mail_smtpport' => '',
  'mail_smtpauth' => 1,
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => ',
  'mail_domain' => '',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'maintenance' => false,
  'loglevel' => 2,
  'theme' => '',
);```

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

Since my reverse proxy is performing normal to my other services, I think it may not be the problem. Please ask me to post if you think it is useful.

PASTE HERE

Seems that you have problems with the collation of the database…
Is apcu configured for running in cli as cron?
The Nextcloud datadirectory should NEVER be a subfolder of the folder that is presented to public…

Thank you for replying. After done several tries and searches, I find that this is a really common problem among fpm servers. I did seperate my data dir from the /var/www/html, which is presented to the public. And I even created a completely new instance to avoid any other factors. But the truth is the cpu usage comes back to 100% everytime. I tried different images (22-fpm-alpine, 21-fpm) but always end up in the same result.

Using Htop I can know that the main cpu comsumer is a command called 'php-fpm pool www ', every single of this command can comsume up to 50% of my cpu. I searched this term and found this is a persistent problem from very early on (a discussion here). I don’t get any other clue about how this happens and why this didn’t raise the attention of nextcloud team, since I think this is almost definitely going to occur when you were using php-fpm