Analysis of GLOBAL STATUS and VARIABLES:
Observations:
- Version: 10.4.12-MariaDB
- 31.4 GB of RAM
- Uptime = 10d 15:46:58
- It appears that you are running both MyISAM and InnoDB.
- 239 QPS
The More Important Issues:
If you have any MyISAM tables, consider changing them to InnoDB. (But not the tables in the mysql
database.) http://mysql.rjweb.org/doc.php/myisam2innodb
innodb_buffer_pool_size
is being pulled in both directions. It could be larger, but there does not seem to be enough data to warrant it to be as big as it currently is. So, just leave it alone, contrary to the details below.
You are hitting max_connections
. If you are getting compaints of "out of connections" or "connection denied", let's discuss the various remedies. The quick fixes are increase max_connections (now 151) and/or decrease wait_timeout (now 28800), but there may be underlying problems that should be fixed. A common possibility is Apache having too many "children".
SHOW TABLES
is being run about 40 times per minute -- why?
Handler_discover
is > 0. Are you using NDB?
Do you have some "prefix" indexes? If so, let's look at them and their usage. There may be some improvements to be had.
Recommended changes to VARIABLES:
innodb_log_file_size = 300M -- Caution. If this turns out to be difficult to change, leave it alone.
innodb_adaptive_hash_index = OFF
query_cache_type = OFF -- It is currently not effective, and causing a lot of overhead
query_cache_size = 0
Details and other observations:
( innodb_buffer_pool_size ) = 18G / 33715493273.6 = 57.3%
-- % of RAM used for InnoDB buffer_pool
-- Set to about 70% of available RAM. (To low is less efficient; too high risks swapping.)
( innodb_buffer_pool_instances ) = 18
-- Recommend no more than 16. (Beginning to go away in 10.5)
( innodb_lru_scan_depth * innodb_page_cleaners ) = 1,024 * 4 = 4,096
-- Amount of work for page cleaners every second.
-- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixable by lowering lru_scan_depth: Consider 1000 / innodb_page_cleaners (now 4). Also check for swapping.
( innodb_lru_scan_depth ) = 1,024
-- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixed by lowering lru_scan_depth
( innodb_io_capacity ) = 200
-- When flushing, use this many IOPs.
-- Reads could be slugghish or spiky.
( Innodb_buffer_pool_pages_free / Innodb_buffer_pool_pages_total ) = 631,176 / 1154160 = 54.7%
-- Pct of buffer_pool currently not in use
-- innodb_buffer_pool_size (now 19327352832) is bigger than necessary?
( Innodb_log_writes ) = 24,075,529 / 920818 = 26 /sec
( Innodb_os_log_written / (Uptime / 3600) / innodb_log_files_in_group / innodb_log_file_size ) = 73,937,686,528 / (920818 / 3600) / 2 / 48M = 2.87
-- Ratio
-- (see minutes)
( Uptime / 60 * innodb_log_file_size / Innodb_os_log_written ) = 920,818 / 60 * 48M / 73937686528 = 10.4
-- Minutes between InnoDB log rotations Beginning with 5.6.8, this can be changed dynamically; be sure to also change my.cnf.
-- (The recommendation of 60 minutes between rotations is somewhat arbitrary.) Adjust innodb_log_file_size (now 50331648). (Cannot change in AWS.)
( innodb_flush_method ) = innodb_flush_method = fsync
-- How InnoDB should ask the OS to write blocks. Suggest O_DIRECT or O_ALL_DIRECT (Percona) to avoid double buffering. (At least for Unix.) See chrischandler for caveat about O_ALL_DIRECT
( default_tmp_storage_engine ) = default_tmp_storage_engine =
( innodb_flush_neighbors ) = 1
-- A minor optimization when writing blocks to disk.
-- Use 0 for SSD drives; 1 for HDD.
( innodb_io_capacity ) = 200
-- I/O ops per second capable on disk . 100 for slow drives; 200 for spinning drives; 1000-2000 for SSDs; multiply by RAID factor.
( sync_binlog ) = 0
-- Use 1 for added security, at some cost of I/O =1 may lead to lots of "query end"; =0 may lead to "binlog at impossible position" and lose transactions in a crash, but is faster. 0 is OK for Galera.
( innodb_adaptive_hash_index ) = innodb_adaptive_hash_index = ON
-- Usually should be ON.
-- There are cases where OFF is better. See also innodb_adaptive_hash_index_parts (now 8) (after 5.7.9) and innodb_adaptive_hash_index_partitions (MariaDB and Percona). ON has been implicated in rare crashes (bug 73890). 10.5.0 decided to default OFF.
( innodb_print_all_deadlocks ) = innodb_print_all_deadlocks = OFF
-- Whether to log all Deadlocks.
-- If you are plagued with Deadlocks, turn this on. Caution: If you have lots of deadlocks, this may write a lot to disk.
( character_set_server ) = character_set_server = latin1
-- Charset problems may be helped by setting character_set_server (now latin1) to utf8mb4. That is the future default.
( local_infile ) = local_infile = ON
-- local_infile (now ON) = ON is a potential security issue
( Key_blocks_used * 1024 / key_buffer_size ) = 426 * 1024 / 128M = 0.33%
-- Percent of key_buffer used . High-water-mark.
-- Lower key_buffer_size (now 134217728) to avoid unnecessary memory usage.
( Key_writes / Key_write_requests ) = 10,712,314 / 22041880 = 48.6%
-- key_buffer effectiveness for writes
-- If you have enough RAM, it would be worthwhile to increase key_buffer_size (now 134217728).
( query_cache_size ) = 1M
-- Size of QC
-- Too small = not of much use. Too large = too much overhead. Recommend either 0 or no more than 50M.
( Qcache_lowmem_prunes ) = 63,676,293 / 920818 = 69 /sec
-- Running out of room in QC
-- increase query_cache_size (now 1048576)
( Qcache_lowmem_prunes/Qcache_inserts ) = 63,676,293/74322826 = 85.7%
-- Removal Ratio (frequency of needing to prune due to not enough memory)
( Qcache_not_cached ) = 42,503,443 / 920818 = 46 /sec
-- SQL_CACHE attempted, but ignored
-- Rethink caching; tune qcache
( Qcache_hits / Qcache_inserts ) = 21,642,863 / 74322826 = 0.291
-- Hit to insert ratio -- high is good
-- Consider turning off the query cache.
( Qcache_hits / (Qcache_hits + Com_select) ) = 21,642,863 / (21642863 + 148412902) = 12.7%
-- Hit ratio -- SELECTs that used QC
-- Consider turning off the query cache.
( Qcache_hits / (Qcache_hits + Qcache_inserts + Qcache_not_cached) ) = 21,642,863 / (21642863 + 74322826 + 42503443) = 15.6%
-- Query cache hit rate
-- Probably best to turn off the QC.
( (query_cache_size - Qcache_free_memory) / Qcache_queries_in_cache / query_alloc_block_size ) = (1M - 80152) / 454 / 16384 = 0.13
-- query_alloc_block_size vs formula
-- Adjust query_alloc_block_size (now 16384)
( Created_tmp_tables ) = 52,379,234 / 920818 = 57 /sec
-- Frequency of creating "temp" tables as part of complex SELECTs.
( Created_tmp_disk_tables ) = 12,852,371 / 920818 = 14 /sec
-- Frequency of creating disk "temp" tables as part of complex SELECTs
-- increase tmp_table_size (now 16777216) and max_heap_table_size (now 16777216).
Check the rules for temp tables on when MEMORY is used instead of MyISAM. Perhaps minor schema or query changes can avoid MyISAM.
Better indexes and reformulation of queries are more likely to help.
( Created_tmp_disk_tables / Questions ) = 12,852,371 / 219809523 = 5.8%
-- Pct of queries that needed on-disk tmp table.
-- Better indexes / No blobs / etc.
( Select_full_join / Com_select ) = 16,794,986 / 148412902 = 11.3%
-- % of selects that are indexless joins
-- Add suitable index(es) to tables used in JOINs.
( Com_insert + Com_delete + Com_delete_multi + Com_replace + Com_update + Com_update_multi ) = (46913103 + 16078 + 0 + 0 + 772352 + 0) / 920818 = 52 /sec
-- writes/sec
-- 50 writes/sec + log flushes will probably max out I/O write capacity of normal drives
( slow_query_log ) = slow_query_log = OFF
-- Whether to log slow queries. (5.1.12)
( back_log ) = 80
-- (Autosized as of 5.6.6; based on max_connections)
-- Raising to min(150, max_connections (now 151)) may help when doing lots of connections.
( Max_used_connections / max_connections ) = 152 / 151 = 100.7%
-- Peak % of connections
-- increase max_connections (now 151) and/or decrease wait_timeout (now 28800)
Abnormally small:
Created_tmp_files = 0.098 /HR
innodb_page_cleaners / innodb_buffer_pool_instances = 0.222
innodb_spin_wait_delay = 4
Abnormally large:
Aria_transaction_log_syncs = 13,051
Com_show_tables = 0.61 /sec
Com_show_warnings = 39 /HR
Connection_errors_internal = 0.0039 /HR
Handler_discover = 0.2 /HR
Handler_read_key = 71904 /sec
Innodb_buffer_pool_read_requests = 681014 /sec
Innodb_buffer_pool_read_requests / (Innodb_buffer_pool_read_requests + Innodb_buffer_pool_reads ) = 100.0%
Innodb_rows_updated = 354 /sec
Innodb_secondary_index_triggered_cluster_reads = 163096 /sec
Threads_cached = 148
performance_schema_max_cond_classes = 90
Abnormal strings:
Innodb_have_punch_hole = OFF
aria_recover_options = BACKUP,QUICK
disconnect_on_expired_password = OFF
ft_boolean_syntax = + -><()~*:
innodb_fast_shutdown = 1
log_output = TABLE
log_slow_admin_statements = ON
myisam_stats_method = NULLS_UNEQUAL
old_alter_table = DEFAULT
optimizer_trace = enabled=off
profiling = ON