MariaDB may show high CPU utilization (e.g., 50%) even when it appears idle due to several reasons. Here are common causes with examples:
Background Processes: MariaDB runs background tasks like purging binary logs, flushing buffers, or InnoDB checkpointing. These tasks consume CPU even if no active queries are executed.
Example: If innodb_flush_log_at_trx_commit=1 (default), frequent log flushing can spike CPU.
Query Cache or Statistics Updates: The query cache may be invalidating entries, or the optimizer is updating statistics.
Example: Frequent ANALYZE TABLE operations or a large query cache with many invalidations.
Connection Overhead: Idle connections still consume resources if connection pooling is misconfigured.
Example: A connection pool with too many idle connections (e.g., 100+ connections with no active queries).
System-Level Tasks: The OS or other processes (e.g., mysqld_safe) may temporarily spike CPU, affecting MariaDB’s metrics.
Resource-Intensive Configurations: Settings like sync_binlog=1 or high innodb_io_capacity can cause frequent disk I/O, leading to CPU wait states.
Mitigation:
SHOW PROCESSLIST to check for hidden queries.slow_query_log=ON) to identify inefficient queries.query_cache_size if unused).