캐싱으로 인한 MySQL 성능 문제

캐싱으로 인한 MySQL 성능 문제
perl mysqltuner.pl --host 127.0.0.1

[--] Skipped version check for MySQLTuner script
[--] Performing tests on 127.0.0.1:3306
[!!] Successfully authenticated with no password - SECURITY RISK!
[!!] failed to execute: SHOW SLAVE STATUS\G
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW SLAVE HOSTS\G
[!!] FAIL Execute SQL / return code: 256
[OK] Currently running supported MySQL version 10.4.17-MariaDB
[OK] Operating on 64-bit architecture
 
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE 
[!!] InnoDB is enabled but isn't being used
[OK] Total fragmented tables: 0
 
-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
 
-------- Security Recommendations ------------------------------------------------------------------
[--] Skipped due to none of known auth columns exists
 
-------- CVE Security Recommendations --------------------------------------------------------------
[!!] CVE-2021-27928(<= 10.4.17) : "A remote code execution issue was discovered in MariaDB 10.2 before 10.2.37
[!!] 1 CVE(s) found for your MySQL release.
 
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 2d 20h 44m 2s (48K q [0.196 qps], 384 conn, TX: 885M, RX: 18M)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 1.8G
[--] Max MySQL memory    : 46.5G
[--] Other process memory: 0B
[--] Total buffers: 8.3G global + 258.9M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 11.3G (617.92% of installed RAM)
[!!] Maximum possible memory usage: 46.5G (2537.09% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/48K)
[OK] Highest usage of available connections: 7% (12/151)
[OK] Aborted connections: 1.30%  (5/384)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 19.8% (11K cached / 56K selects)
[!!] Query cache prunes per day: 7584
[OK] Sorts requiring temporary tables: 0% (1 temp sorts / 9K sorts)
[OK] No joins without indexes
[OK] Temporary tables created on disk: 14% (1K on disk / 10K total)
[OK] Thread cache hit rate: 80% (73 created / 384 connections)
[OK] Table cache hit rate: 99% (74K hits / 74K requests)
[OK] table_definition_cache(400) is upper than number of tables(77)
[OK] Open file limit used: 0% (48/32K)
[OK] Table locks acquired immediately: 99% (5K immediate / 5K locks)
 
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.
 
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 1 thread(s).
[--] Using default value is good enough for your version (10.4.17-MariaDB)
 
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (24M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/0B
 
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[!!] No tables are Innodb
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 8.0G/0B
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (1.171875 %): 48.0M * 2/8.0G should be equal to 25%
[OK] InnoDB buffer pool instances: 8
[--] Number of InnoDB Buffer Pool Chunk : 64 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% (609465732 hits/ 609485088 total)
[!!] InnoDB Write Log efficiency: 88.45% (3109 hits/ 3515 total)
[OK] InnoDB log waits: 0.00% (0 waits / 406 writes)
 
-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/0B
[!!] Aria pagecache hit rate: 94.9% (28K cached / 1K reads)
 
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
 
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
 
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
 
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

우리 프로덕션 서버 중 하나에 성능 문제가 있는데 대부분 MySQL과 관련이 있다는 것을 알았고 MySQLTuner를 실행한 후 몇 가지 흥미로운 점을 발견했습니다. 놀랍게도 인덱스가 없으면 조인이 없어서 별로 할 수 없을 것 같고 캐싱 때문인 것 같으며 W3T Total Cache를 사용하고 있는 것으로 알고 있지만 에서는 일반 구성 외에는 구성이 보이지 않습니다. WP 관리자 패널에 추가 쿼리를 캐시할 수 있는 방법이 있는지 궁금합니다. 어떤 이유로 쿼리 중 20%만 캐시된 것 같기 때문입니다. 그리고 쿼리 캐시 정리가 너무 높기 때문에 해당 측정항목을 올바르게 이해하고 있는지, 최소한 40%를 캐시할 수 있도록 매일 정리하는 횟수를 줄일 수 있는지 궁금합니다. 또한 RAM을 늘리면 서버에 도움이 될 수 있다고 생각하지만 이는 거의 다른 문제입니다.

다음이 가장 관련성이 높은 것 같습니다.

[!!] Maximum reached memory usage: 11.3G (617.92% of installed RAM)
[!!] Maximum possible memory usage: 46.5G (2537.09% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 19.8% (11K cached / 56K selects)
[!!] Query cache prunes per day: 7584

답변1

모든 테이블은 MyISAM 테이블인 것 같습니다. 요즘에는 모든 테이블을 InnoDB 테이블로 설정하는 것이 좋습니다.

MySQL 쿼리 캐시는 다양한 이유로 인해 더 이상 사용되지 않는 기능입니다.문제따라서 비활성화하는 것이 가장 좋습니다.

모든 테이블을 InnoDB로 변경한 후 MySQLTuner를 다시 실행하고 권장 사항에 따라 InnoDB 버퍼 풀을 조정합니다.

귀하의 버전에는 공개 취약점이 있으므로 MySQL 서버도 업그레이드해야 합니다.

답변2

나는 그것을 의심한다교환진짜 문제입니다. RAM을 과도하게 할당했습니다. 나에게 튀어 나온 것은 다음과 같습니다.

Physical Memory     : 1.8G
InnoDB buffer pool / data size: 8.0G/0B
Highest usage of available connections: 7% (12/151)

InnoDB로 전환하고 QC를 끈 후(Tero가 권장하는 대로) RAM이 주어진 innodb_buffer_pool_size.

보다 구체적으로 다음과 같이 구성을 변경합니다.

innodb_buffer_pool_size = 500M
max_connections = 30
query_cache_type = 0
query_cache_size = 0
key_buffer_size = 24M

변경한 후에도 여전히 문제가 있는 경우 dba.stackexchange.com에서 새 질문을 시작하세요. MySQL/MariaDB 구성을 위한 더 나은 포럼입니다.

관련 정보