High CPU usage for CalDAV

Nextcloud version: 22.1.1
Operating system and version: Oracle Enterprise Linux 7.9 x64 (RHEL7)
Apache or nginx version: 2.4.6-97
PHP version: 7.4.24
Hardware: 4vCPU, 8 GB RAM, 50 GB disk virtualized on Oracle VM 3.4

We are facing constant high CPU usage when using CalDAV component of NextCloud. CalDAV is only app we use from NextCloud, total 40 users sharing all calendars among each other. Calendard are used in web interface, as well as in Thunderbird with Lightning, Provider for CalDAV and TBSync add-ons.

Even when one user is refreshing web interface, with everything else turned off (calendars removed from all Thunderbirds), all CPU cores are on ~40% load for 30 sec. by apache and mysql. When we add more users, server is unusable.

%Cpu0  : 19.4 us,  9.1 sy,  0.0 ni, 67.2 id,  0.9 wa,  2.6 hi,  0.4 si,  0.4 st
%Cpu1  : 64.2 us,  9.3 sy,  0.0 ni, 22.8 id,  0.5 wa,  2.6 hi,  0.5 si,  0.0 st
%Cpu2  : 39.2 us, 11.7 sy,  0.0 ni, 45.5 id,  0.5 wa,  2.3 hi,  0.9 si,  0.0 st
%Cpu3  : 39.4 us, 13.1 sy,  0.0 ni, 43.4 id,  0.0 wa,  3.2 hi,  0.9 si,  0.0 st
KiB Mem :  8141488 total,  6670448 free,   656732 used,   814308 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  7214664 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  770 mysql     20   0 2841076 459468  32220 S  56.2  5.6   1:16.71 mysqld
  928 apache    20   0  824084  64448  47040 S  41.4  0.8   0:27.89 httpd
 1000 apache    20   0  711208  20188  10188 S  35.9  0.2   0:01.09 httpd
  801 apache    20   0  824156  65488  47976 S  29.3  0.8   0:42.01 httpd
  962 apache    20   0  822012  59060  43736 S  21.4  0.7   0:03.50 httpd
  999 apache    20   0  823768  59988  42908 R  17.4  0.7   0:01.52 httpd
  916 apache    20   0  824372  64520  46756 S  15.8  0.8   0:33.50 httpd
  929 apache    20   0  824016  60144  42804 R  15.5  0.7   0:26.46 httpd
  923 apache    20   0  824388  63796  46036 S  15.1  0.8   0:17.95 httpd

NextCloud is optimized according to documentation:
php-opcache
php-pecl-apcu
my.cnf
pdo_mysql

All similar posts on forum were analyzed and everything relevant was done, what includes cache cleanup, emptying InnoDB oc_authtoken table etc, no success.

DB slow log shows occasional entry:
UPDATE oc_authtoken SET password = *** WHERE id = ***;
All other logs are clean - Nextcloud log, Apache log.

config.php

<?php
$CONFIG = array (
  'instanceid' => '*****',
  'passwordsalt' => '*****',
  'secret' => '*****',
  'trusted_domains' =>
  array (
    0 => 'cal.laserline.hr:****',
  ),
  'datadirectory' => '/laserline/cloud',
  'dbtype' => 'mysql',
  'version' => '22.1.1.2',
  'overwrite.cli.url' => 'https://cal.laserline.hr:****',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '****',
  'dbpassword' => '*****',
  'installed' => true,
  'login_form_autocomplete' => false,
  'auth.webauthn.enabled' => false,
  'lost_password_link' => 'disabled',
  'maintenance' => false,
  'memcache.local' => '\OC\Memcache\APCu',
);

Server is unusable in current state, please advise how to optimize it so that we can use calendars.

Thanks, regards
Ivica Glavocic

1 Like