Hello all,
Im having issues with CPU load on Mysql, sometimes reach more of 500% load.
My Hardware:
Cpu: Intel(R) Xeon(R) CPU E3-1245 V2 @ 3.40GHz
Ram: 32GB
Mysqltuner Report:
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.7.26-log
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ----------------------
[OK] Log file /var/log/mysql/error.log exists
[--] Log file: /var/log/mysql/error.log (13M)
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[OK] Log file /var/log/mysql/error.log is readable.
[!!] /var/log/mysql/error.log contains 26 warning(s).
[!!] /var/log/mysql/error.log contains 6970 error(s).
[--] 5 start(s) detected in /var/log/mysql/error.log
[--] 1) 2022-12-15T11:28:14.771917Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 2) 2022-11-22T20:20:05.701938Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 3) 2022-09-19T17:03:07.740843Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 4) 2022-08-18T23:00:10.145430Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 5) 2022-07-12T15:57:32.405388Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 0 shutdown(s) detected in /var/log/mysql/error.log
-------- Storage Engine Statistics ---------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +My ISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 12.0M (Tables: 106)
[--] Data in InnoDB tables: 12.4G (Tables: 8126)
[!!] Total fragmented tables: 1
-------- Analysis Performance Metrics ------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
-------- Views Metrics ---------------------------------------------------------
-------- Triggers Metrics ------------------------------------------------------
-------- Routines Metrics ------------------------------------------------------
-------- Security Recommendations ----------------------------------------------
[OK] No Role user detected
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.
-------- Performance Metrics ---------------------------------------------------
[--] Up for: 23h 22m 23s (226M q [2K qps], 234K conn, TX: 272G, RX: 46G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory : 31.3G
[--] Max MySQL memory : 145.0G
[--] Other process memory: 0B
[--] Total buffers: 18.2G global + 257.1M per thread (505 max threads)
[--] Performance_schema Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 34.5G (110.28% of installed RAM)
[!!] Maximum possible memory usage: 145.0G (463.09% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (384/226M)
[OK] Highest usage of available connections: 12% (65/505)
[OK] Aborted connections: 0.01% (25/234485)
[!!] CPanel and Flex system skip-name-resolve should be on
[OK] Query cache is disabled by default due to mutex contention on multiprocesso r machines.
[OK] Sorts requiring temporary tables: 0% (61K temp sorts / 41M sorts)
[!!] Joins performed without indexes: 13004883
[OK] Temporary tables created on disk: 6% (1M on disk / 28M total)
[OK] Thread cache hit rate: 99% (2K created / 234K connections)
[OK] Table cache hit rate: 98% (359M hits / 366M requests)
[!!] table_definition_cache (4096) is less than number of tables (8511)
[OK] Open file limit used: 0% (50/40K)
[OK] Table locks acquired immediately: 100% (116K immediate / 116K locks)
-------- Performance schema ----------------------------------------------------
[!!] Performance_schema should be activated.
[--] Sys schema is installed.
-------- ThreadPool Metrics ----------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics --------------------------------------------------------
[!!] Key buffer used: 19.5% (1.6M used / 8.0M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/3.3M
[!!] Read Key buffer hit rate: 94.0% (188K cached / 11K reads)
[!!] Write Key buffer hit rate: 93.1% (12K cached / 11K writes)
-------- InnoDB Metrics --------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 18.0G / 12.4G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (5.55555555555556%): 5 12.0M * 2 / 18.0G should be equal to 25%
[!!] InnoDB buffer pool instances: 8
[--] Number of InnoDB Buffer Pool Chunk: 144 for 8 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb _buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (52196370666 hits / 52196704094 tota l)
[OK] InnoDB Write log efficiency: 96.88% (28858402 hits / 29786657 total)
[OK] InnoDB log waits: 0.00% (0 waits / 928255 writes)
-------- Aria Metrics ----------------------------------------------------------
[--] Aria Storage Engine not available.
-------- TokuDB Metrics --------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics --------------------------------------------------------
[--] XtraDB is disabled.
--------------------
[--] Galera is disabled.
-------- Replication Metrics ---------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server
-------- Recommendations -------------------------------------------------------
General recommendations:
Check warning line(s) in /var/log/mysql/error.log file
Check error line(s) in /var/log/mysql/error.log file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE `freelanc_excitasy`.`ps_product_lang`; -- can free 1490 MB
Total freed space after theses OPTIMIZE TABLE : 1490 Mb
103 CVE(s) found for your MySQL release. Consider upgrading your version !
MySQL was started within the last 24 hours: recommendations may be inaccurat e
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
name resolution is enabled due to cPanel doesn't support this disabled.
We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
See MySQL: Welcome
(specially the conclusions at the bottom of the page).
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read t his: MySQL :: MySQL 8.0 Reference Manual :: 15.6.5 Redo Log
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
skip-name-resolve=0
join_buffer_size (> 256.0K, or always use indexes with JOINs)
table_definition_cache (4096) > 8511 or -1 (autosizing if supported)
performance_schema=ON
key_buffer_size (~ 1M)
innodb_log_file_size should be (=2G) if possible, so InnoDB total log files size equals 25% of buffer pool size.
innodb_buffer_pool_instances(=18)
My.cnf file
[mysqld]
default-storage-engine = InnoDB
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
socket = /var/lib/mysql/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
character-set-server = utf8
collation-server = utf8_bin
performance-schema = 0
max_allowed_packet = 256M
group_concat_max_len = 1000000
# MyISAM
# DATA STORAGE
datadir = /var/lib/mysql
# CACHE / LIMITS
tmp_table_size = 128M
max_heap_table_size = 128M
query_cache_size = 64M
max_connections = 505
open_files_limit=40000
table_open_cache = 4096
table_definition_cache = 4096
max_connections = 505
max_user_connections = 500
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links = 0
# InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 18G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
# Logging
log_warnings = 4
log_error = /var/log/mysql/error.log
log-error = /var/log/mysql/error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 5
log_queries_not_using_indexes = 0
min_examined_row_limit = 100
Im having issues with CPU load on Mysql, sometimes reach more of 500% load.
My Hardware:
Cpu: Intel(R) Xeon(R) CPU E3-1245 V2 @ 3.40GHz
Ram: 32GB
Mysqltuner Report:

[OK] Currently running supported MySQL version 5.7.26-log
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ----------------------
[OK] Log file /var/log/mysql/error.log exists
[--] Log file: /var/log/mysql/error.log (13M)
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[OK] Log file /var/log/mysql/error.log is readable.
[!!] /var/log/mysql/error.log contains 26 warning(s).
[!!] /var/log/mysql/error.log contains 6970 error(s).
[--] 5 start(s) detected in /var/log/mysql/error.log
[--] 1) 2022-12-15T11:28:14.771917Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 2) 2022-11-22T20:20:05.701938Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 3) 2022-09-19T17:03:07.740843Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 4) 2022-08-18T23:00:10.145430Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 5) 2022-07-12T15:57:32.405388Z 0 [Note] /usr/sbin/mysqld: ready for connect ions.
[--] 0 shutdown(s) detected in /var/log/mysql/error.log
-------- Storage Engine Statistics ---------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +My ISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 12.0M (Tables: 106)
[--] Data in InnoDB tables: 12.4G (Tables: 8126)
[!!] Total fragmented tables: 1
-------- Analysis Performance Metrics ------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
-------- Views Metrics ---------------------------------------------------------
-------- Triggers Metrics ------------------------------------------------------
-------- Routines Metrics ------------------------------------------------------
-------- Security Recommendations ----------------------------------------------
[OK] No Role user detected
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.
-------- Performance Metrics ---------------------------------------------------
[--] Up for: 23h 22m 23s (226M q [2K qps], 234K conn, TX: 272G, RX: 46G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory : 31.3G
[--] Max MySQL memory : 145.0G
[--] Other process memory: 0B
[--] Total buffers: 18.2G global + 257.1M per thread (505 max threads)
[--] Performance_schema Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 34.5G (110.28% of installed RAM)
[!!] Maximum possible memory usage: 145.0G (463.09% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (384/226M)
[OK] Highest usage of available connections: 12% (65/505)
[OK] Aborted connections: 0.01% (25/234485)
[!!] CPanel and Flex system skip-name-resolve should be on
[OK] Query cache is disabled by default due to mutex contention on multiprocesso r machines.
[OK] Sorts requiring temporary tables: 0% (61K temp sorts / 41M sorts)
[!!] Joins performed without indexes: 13004883
[OK] Temporary tables created on disk: 6% (1M on disk / 28M total)
[OK] Thread cache hit rate: 99% (2K created / 234K connections)
[OK] Table cache hit rate: 98% (359M hits / 366M requests)
[!!] table_definition_cache (4096) is less than number of tables (8511)
[OK] Open file limit used: 0% (50/40K)
[OK] Table locks acquired immediately: 100% (116K immediate / 116K locks)
-------- Performance schema ----------------------------------------------------
[!!] Performance_schema should be activated.
[--] Sys schema is installed.
-------- ThreadPool Metrics ----------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics --------------------------------------------------------
[!!] Key buffer used: 19.5% (1.6M used / 8.0M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/3.3M
[!!] Read Key buffer hit rate: 94.0% (188K cached / 11K reads)
[!!] Write Key buffer hit rate: 93.1% (12K cached / 11K writes)
-------- InnoDB Metrics --------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 18.0G / 12.4G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (5.55555555555556%): 5 12.0M * 2 / 18.0G should be equal to 25%
[!!] InnoDB buffer pool instances: 8
[--] Number of InnoDB Buffer Pool Chunk: 144 for 8 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb _buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (52196370666 hits / 52196704094 tota l)
[OK] InnoDB Write log efficiency: 96.88% (28858402 hits / 29786657 total)
[OK] InnoDB log waits: 0.00% (0 waits / 928255 writes)
-------- Aria Metrics ----------------------------------------------------------
[--] Aria Storage Engine not available.
-------- TokuDB Metrics --------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics --------------------------------------------------------
[--] XtraDB is disabled.
--------------------
[--] Galera is disabled.
-------- Replication Metrics ---------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server
-------- Recommendations -------------------------------------------------------
General recommendations:
Check warning line(s) in /var/log/mysql/error.log file
Check error line(s) in /var/log/mysql/error.log file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE `freelanc_excitasy`.`ps_product_lang`; -- can free 1490 MB
Total freed space after theses OPTIMIZE TABLE : 1490 Mb
103 CVE(s) found for your MySQL release. Consider upgrading your version !
MySQL was started within the last 24 hours: recommendations may be inaccurat e
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
name resolution is enabled due to cPanel doesn't support this disabled.
We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
See MySQL: Welcome
(specially the conclusions at the bottom of the page).
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read t his: MySQL :: MySQL 8.0 Reference Manual :: 15.6.5 Redo Log
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
skip-name-resolve=0
join_buffer_size (> 256.0K, or always use indexes with JOINs)
table_definition_cache (4096) > 8511 or -1 (autosizing if supported)
performance_schema=ON
key_buffer_size (~ 1M)
innodb_log_file_size should be (=2G) if possible, so InnoDB total log files size equals 25% of buffer pool size.
innodb_buffer_pool_instances(=18)

My.cnf file

default-storage-engine = InnoDB
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
socket = /var/lib/mysql/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
character-set-server = utf8
collation-server = utf8_bin
performance-schema = 0
max_allowed_packet = 256M
group_concat_max_len = 1000000
# MyISAM
# DATA STORAGE
datadir = /var/lib/mysql
# CACHE / LIMITS
tmp_table_size = 128M
max_heap_table_size = 128M
query_cache_size = 64M
max_connections = 505
open_files_limit=40000
table_open_cache = 4096
table_definition_cache = 4096
max_connections = 505
max_user_connections = 500
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links = 0
# InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 18G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
# Logging
log_warnings = 4
log_error = /var/log/mysql/error.log
log-error = /var/log/mysql/error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 5
log_queries_not_using_indexes = 0
min_examined_row_limit = 100

Last edited by a moderator: