1

i need some suggestions in improving MySQL performance, i didn't find any issues in general but i feel MySQL is taking more CPU than before.

Below is the output from mysqltuner.pl

 >>  MySQLTuner 1.7.7 - Major Hayden <major@mhtx.net>

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.6.43
[OK] Operating on 64-bit architecture


-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 441M (Tables: 4070)
[--] Data in InnoDB tables: 1G (Tables: 10648)
[--] Data in MEMORY tables: 0B (Tables: 23)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

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

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 1d 12h 51m 34s (12M q [92.733 qps], 156K conn, TX: 83G, RX: 3G)
[--] Reads / Writes: 97% / 3%
[--] Binary logging is disabled
[--] Physical Memory     : 31.2G
[--] Max MySQL memory    : 1.8G
[--] Other process memory: 4.8G
[--] Total buffers: 1.2G global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 487M
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 1.7G (5.48% of installed RAM)
[OK] Maximum possible memory usage: 1.8G (5.90% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (15/12M)
[OK] Highest usage of available connections: 21% (32/151)
[OK] Aborted connections: 0.03%  (42/156614)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (22K temp sorts / 2M sorts)
[!!] Joins performed without indexes: 5039
[!!] Temporary tables created on disk: 81% (1M on disk / 1M total)
[OK] Thread cache hit rate: 92% (11K created / 156K connections)
[!!] Table cache hit rate: 0% (4K open / 6M opened)
[OK] Open file limit used: 4% (2K/65K)
[OK] Table locks acquired immediately: 99% (14M immediate / 14M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 487.4M
[--] Sys schema isn't installed.

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 54.9% (4M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/56.8M
[OK] Read Key buffer hit rate: 100.0% (4B cached / 1M reads)
[!!] Write Key buffer hit rate: 0.0% (1B cached / 44K writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 1.2G/1.0G
[OK] Ratio InnoDB log file size / InnoDB Buffer pool size: 150.0M * 2/1.2G should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (9622783466 hits/ 9622844978 total)
[OK] InnoDB Write log efficiency: 92.12% (3418042 hits/ 3710409 total)
[OK] InnoDB log waits: 0.00% (0 waits / 292367 writes)

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

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.

-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.

-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: STATEMENT
[--] XA support enabled: ON
Use of uninitialized value $_[0] in concatenation (.) or string at
        mysqltuner.pl line 233 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl will try to tell you
    the name of the variable (if any) that was undefined.  In some cases
    it cannot do this, so it also tells you what operation you used the
    undefined value in.  Note, however, that perl optimizes your program
    anid the operation displayed in the warning may not necessarily appear
    literally in your program.  For example, "that $foo" is usually
    optimized into "that " . $foo, and the warning will refer to the
    concatenation (.) operator, even though there is no . in
    your program.

[--]
[--]
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Set up a Secure Password for user@host ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    Adjust your join queries to always utilize indexes
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Increase table_open_cache gradually to avoid file descriptor limits
    Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
    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 (65536) variable
    should be greater than table_open_cache (4000)
    Consider installing Sys schema from https://github.com/mysql/mysql-sys
Variables to adjust:
    join_buffer_size (> 256.0K, or always use indexes with joins)
    tmp_table_size (> 1K)
    max_heap_table_size (> 256M)
    table_open_cache (> 4000) 

my.cnf file content

[mysqld]
innodb_file_per_table=1
performance-schema=1
max_allowed_packet=268435456
open_files_limit=50000
innodb_buffer_pool_size=1200M

table_open_cache=4000
query_cache_type = 0
query_cache_size = 0
query_cache_limit = 5M
thread_cache_size = 2
tmp_table_size = 1k
max_heap_table_size=256M
wait_timeout = 28800
innodb_buffer_pool_instances = 1
innodb_log_file_size = 150M

Thanks in advance for your valuable time.

  • You can't "tune away performance problems". You need to find the slow queries and work on them. More discussion here – Rick James Apr 21 at 2:22
0

You should try to set tmp_table_size to at least 1M to ruled out spill over to disk if any temp table is being created by your query.

Would you please paste the output of

show variables like 'innodb%thread%';

Further, please check if you have any changes in underlying DISKs.

  • 1
    Thanks for the suggestion. Below is the output for "show variables like 'innodb%thread%';" innodb_purge_threads 1 innodb_read_io_threads 4-------- innodb_thread_concurrency 0--------- innodb_thread_sleep_delay 10000------------ innodb_write_io_thread 4 – Avi88 Apr 4 at 7:42
  • I see. innodb_thread_concurrency 0 is allowing MySQL to consume your CPU. You need to set it to innodb_thread_concurrency= (total cores of CPU on DB server-20%). This will limit your CPU to 70-80% of utilizations. For example if you have 32 cores in your system you may set it 25 to (32 - 32*.2) – thisissanjeeva.com Apr 4 at 9:31
0

Suggestions to consider for your my.cnf [mysqld] section

table_open_cache=15000  # from 4000 to support your table count
query_cache_limit=0  # from 5M to conserve RAM (QC is OFF and not used)
thread_cache_size=100  # from 2 to support your 32 max_used_connections with spares
tmp_table_size=256M  # from 1k to match max_heap_table_size
key_buffer_size=32M  # from 8M for better coverage of your ~ 57M MyISAM indexes
key_cache_age_threshold=7200  # from 300 seconds to reduce key_reads RatePerSecond

Disclaimer: I am the content author of web site mentioned in my profile, Network profile and can provide additional suggestions to improve performance of your instance.

  • Thank you very much. i will implement your suggestions and post updated mysqltuner report after 24hrs – Avi88 Apr 8 at 8:50
  • When you post the new mysqltuner report, please put the date in your addition of the new data. Thanks – Wilson Hauck Apr 11 at 16:27
  • @Avi88 Is your system running better? Posting a new mysqltuner report would be helpful after running for minimum of 1 complete working day/24 or more hours. – Wilson Hauck May 11 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.