Suggestion About MySQL (5.7) Optimization
Posted by: Jack UK
Date: February 01, 2020 12:50PM

Hi everyone,

Firstly, I'm new here. If the topic is not in right category for this.

I have a cloud machine on AWS. The machine has 2 GB RAM, 1 vCPU, 50 GB SSD.

An open-source, e-commerce script runs on it with PHP 7.3 and MySQL 5.7.

MySQL has arround 300 tables (InnoDB), 2 GB.

I installed MySQL Tunner, is working for 4-5 days.

I'll share the output. Would you comment to them please?


There is no code block in this editor. :/
-----------
>> MySQLTuner 1.7.19 - Major Hayden <major@mhtx.net>
[OK] Currently running supported MySQL version 5.7.26
[OK] Operating on 64-bit architecture

[OK] Log file /opt/bitnami/mysql/data/mysqld.log exists
[--] Log file: /opt/bitnami/mysql/data/mysqld.log(187K)
[OK] Log file /opt/bitnami/mysql/data/mysqld.log is readable.
[OK] Log file /opt/bitnami/mysql/data/mysqld.log is not empty
[OK] Log file /opt/bitnami/mysql/data/mysqld.log is smaller than 32 Mb
[!!] /opt/bitnami/mysql/data/mysqld.log contains 78 warning(s).
[!!] /opt/bitnami/mysql/data/mysqld.log contains 40 error(s).
[--] 25 start(s) detected in /opt/bitnami/mysql/data/mysqld.log
[--] 1) 2020-01-29T10:01:46.722081Z 0 [Note] /opt/bitnami/mysql/bin/mysqld.bin: ready for connections.
...
[--] 10) 2020-01-29T08:30:51.403160Z 0 [Note] /opt/bitnami/mysql/bin/mysqld.bin: ready for connections.
[--] 21 shutdown(s) detected in /opt/bitnami/mysql/data/mysqld.log
[--] 1) 2020-01-29T10:01:42.837601Z 0 [Note] /opt/bitnami/mysql/bin/mysqld.bin: Shutdown complete
...
[--] 10) 2020-01-29T08:11:48.085422Z 0 [Note] /opt/bitnami/mysql/bin/mysqld.bin: Shutdown complete

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in InnoDB tables: 1.3G (Tables: 302)
[--] Data in MyISAM tables: 35.5K (Tables: 6)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'DB_BDLUSR@%' does not specify hostname restrictions.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 3d 7h 39m 27s (80M q [279.115 qps], 147K conn, TX: 81G, RX: 20G)
[--] Reads / Writes: 98% / 2%
[--] Binary logging is disabled
[--] Physical Memory : 2.0G
[--] Max MySQL memory : 6.0G
[--] Other process memory: 0B
[--] Total buffers: 234.0M global + 39.2M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 1.3G (66.70% of installed RAM)
[!!] Maximum possible memory usage: 6.0G (308.25% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/80M)
[OK] Highest usage of available connections: 18% (28/151)
[OK] Aborted connections: 0.00% (2/147769)
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Query cache efficiency: 72.8% (57M cached / 79M selects)
[!!] Query cache prunes per day: 5506703
[OK] Sorts requiring temporary tables: 0% (8K temp sorts / 4M sorts)
[!!] Joins performed without indexes: 57369
[OK] Temporary tables created on disk: 8% (476K on disk / 5M total)
[OK] Thread cache hit rate: 99% (28 created / 147K connections)
[!!] Table cache hit rate: 2% (2K open / 71K opened)
[OK] table_definition_cache(1000) is upper than number of tables(587)
[OK] Open file limit used: 0% (20/5K)
[OK] Table locks acquired immediately: 100% (3K immediate / 3K locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema is installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/55.0K
[OK] Read Key buffer hit rate: 96.8% (2K cached / 78 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 128.0M/1.3G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal to 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 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: 99.80% (1992943853 hits/ 1996852014 total)
[!!] InnoDB Write Log efficiency: 82.08% (2113892 hits/ 2575548 total)
[OK] InnoDB log waits: 0.00% (0 waits / 461656 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- 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: 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:
Control warning line(s) into /opt/bitnami/mysql/data/mysqld.log file
Control error line(s) into /opt/bitnami/mysql/data/mysqld.log file
Restrict Host for 'DB_USR'@% to DB_USR@SpecificDNSorIp
UPDATE mysql.user SET host ='SpecificDNSorIp' WHERE user='DB_USR' AND host ='%'; FLUSH PRIVILEGES;
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
(specially the conclusions at the bottom of the page).
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: https://bit.ly/2Fulv7r
Read this before increasing for MariaDB https://mariadb.com/kb/en/library/optimizing-table_open_cache/
This is MyISAM only table_cache scalability problem, InnoDB not affected.
See more details here: https://bugs.mysql.com/bug.php?id=49177
This bug already fixed in MySQL 5.7.9 and newer MySQL versions.
Beware that open_files_limit (5000) variable
should be greater than table_open_cache (2100)
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU


Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (=0)
query_cache_type (=0)
query_cache_size (> 50M)
join_buffer_size (> 2.0M, or always use indexes with JOINs)
table_open_cache (> 2100)
performance_schema = ON enable PFS
innodb_buffer_pool_size (>= 1.3G) if possible.
innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.



-----------

Many thanks!

Options: ReplyQuote


Subject
Written By
Posted
Suggestion About MySQL (5.7) Optimization
February 01, 2020 12:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.