Nextcloud (mysql apache) use all CPU cores to 100%

Hello everyone. Guys, help, please tell me! On a server with the following characteristics
Intel(R) Xeon(R) Gold 6226 processor with a frequency of 2.70 GHz
and 256 GB of RAM
1 TB nvme
2x8 TB sata
raised postman (postfix dovecote), apache and mysql.
Latest NEXCTLOUD is installed.

Users who simultaneously log in and use mail, joint editing, etc. 200-300 people.
When I open htop during peak hours, I pale from the fact that all 24 cores are clogged at 99-100%. I watch the processes. The processor eats the muscle. RAM is used only 7GB out of 256…
How can I reduce CPU consumption with such attendance, please tell me?
skip_name_resolve = 1
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 7
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_max_dirty_pages_pct = 90
query_cache_type = 1 query_cache_type = 1
query_cache_limit = 128 M
query_cache_min_res_unit = 2k requests
query_cache_size = 2G
tmp_table_size= 128
M max_heap_table_size= 128
M slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 5

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

default character set = utf8mb4

character_set_server = utf8mb4
collation_server = utf8mb4_general_ci transaction_
binlog_format = STRING
innodb_file_format= barracuda
max_connections = 150

Please fill out the support form and also check your /var/www/ nextcloud.log for errors.

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via 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:


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


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 (eg, 20.0.5): replace me
Operating system and version (eg, Ubuntu 20.04): replace me
Apache or nginx version (eg, Apache 2.4.25): replace me
PHP version (eg, 7.4): replace me

The issue you are facing:

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

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:


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


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


Sorry, @just is right, again, remind me of lazy people message :slight_smile:

@sazanof it could be thousands of things, but without the minimum idea of your system specs, the community can’t help you, we only have one Chrystal ball, and the battery is empty.

1 Like

It’s hard to say without lot of input. You system sounds pretty powerful, user count as well - I bet only few people here have experience with such systems.

I would suggest you start with the server tuning guide and work through different sub-systems. You need to analyze where the load comes from. there are different tools specific to every moving part of the system e.g. mysql and maria DB. In general databases perform much faster if they can use lot of RAM - as rule of thumb assign as many memory to DB process as you can - ideally as many as your DB is in size and even more. My private system became much faster after I raised PHP limit from 512MB to 2GB. Did you configure caching in a good way? - see Redis

From my feeling your RAM usage is too low - I would start there and try to put as many part into RAM as possible. Additionally DB and apps should be stored on your NVMe drive and only data on magnetic drives.

1 Like

You know…, adding 2 indexes to table oc_mail_messages solved highload cpu

ALTER TABLE oc_mail_messages ADD INDEX thread_root_id_index (thread_root_id);
ALTER TABLE oc_mail_messages ADD INDEX mailbox_id_index (mailbox_id);

I see a lot of mail problems. Can you uninstall mail app or deactivate mail app. Perhaps then all values decreases. Post then new logs.

That all makes no really sense.
@ChristophWurst Can you help?
I found something about 32 vs. 64 bit.

1 Like

Oh, it’s a separate song. I have a problem about sending something. I can voice it here. when sending, sometimes 500 error comes out. how it happens:

if user@domain.ldap if it does not exist, then the mail application simply returns an error code that something went wrong, instead of specifying the error, or just send it, and postfix will sort it out later.
I have a group in which there are recipients who are not on ldap and for a long time I could not understand what the problem is and why messages are not being sent. Now I know for sure.

Perhaps it is worth mentioning another problem - attachments. when sending an attachment containing Russian characters and spaces, it is not displayed in the MAIL application on WINDOWS10. in roundcube, outlook, all attachments open correctly. but that’s just me… thoughts out loud.