The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mysql High CPU Optimization help

Discussion in 'Workarounds and Optimization' started by Anh Zhang Wei, Dec 17, 2014.

  1. Anh Zhang Wei

    Anh Zhang Wei Registered

    Joined:
    Oct 5, 2014
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello and good Day.
    Sorry for my bad English.
    My Server is running very poorly. I have a high CPU utilization. (80%-95%)
    I ask for Help.

    Processor Information:
    Code:
    Total processors: 4 
    Vendor
            GenuineIntel
    Name
            Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
    Speed
            3300.000 MHz
    Cache
            3072 KB
    My my.cnf
    Code:
    [mysqld]
    max_allowed_packet=268435456
    open_files_limit=10000
    Code:
     >>  MySQLTuner 1.4.0 - Major Hayden <major@mhtx.net>
     >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
     >>  Run with '--help' for additional options and output filtering
    [OK] Currently running supported MySQL version 5.6.21
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
    [--] Data in MyISAM tables: 1G (Tables: 831)
    [--] Data in InnoDB tables: 5M (Tables: 273)
    [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 52)
    [--] Data in MEMORY tables: 496K (Tables: 8)
    [!!] Total fragmented tables: 35
    
    -------- Security Recommendations  -------------------------------------------
    [OK] All database users have passwords assigned
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 4d 6h 44m 39s (32M q [88.579 qps], 1M conn, TX: 1419B, RX: 38B)
    [--] Reads / Writes: 83% / 17%
    [--] Total buffers: 169.0M global + 1.1M per thread (151 max threads)
    [OK] Maximum possible memory usage: 338.9M (5% of installed RAM)
    [OK] Slow queries: 0% (309/32M)
    [OK] Highest usage of available connections: 54% (83/151)
    [OK] Key buffer size / total MyISAM indexes: 8.0M/529.4M
    [OK] Key buffer hit rate: 99.5% (2B cached / 10M reads)
    [!!] Query cache is disabled
    [OK] Sorts requiring temporary tables: 0% (2K temp sorts / 826K sorts)
    [!!] Joins performed without indexes: 15296
    [OK] Temporary tables created on disk: 1% (4K on disk / 364K total)
    [OK] Thread cache hit rate: 97% (36K created / 1M connections)
    [!!] Table cache hit rate: 10% (1K open / 15K opened)
    [OK] Open file limit used: 20% (2K/10K)
    [OK] Table locks acquired immediately: 99% (85M immediate / 85M locks)
    [OK] InnoDB buffer pool / data size: 128.0M/5.6M
    [OK] InnoDB log waits: 0
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Adjust your join queries to always utilize indexes
        Increase table_open_cache gradually to avoid file descriptor limits
        Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
    Variables to adjust:
        query_cache_type (=1)
        join_buffer_size (> 256.0K, or always use indexes with joins)
        table_open_cache (> 2000)
    
    Code:
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
    
    MySQL Version 5.6.21 x86_64
    
    Uptime = 4 days 6 hrs 34 min 35 sec
    Avg. qps = 88
    Total Questions = 32710667
    Threads Connected = 11
    
    Server has been running for over 48hrs.
    It should be safe to follow these recommendations
    
    To find out more information on how each of these
    runtime variables effects performance visit:
    http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html
    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL's Enterprise Monitoring and Advisory Service
    
    SLOW QUERIES
    The slow query log is NOT enabled.
    Current long_query_time = 10.000000 sec.
    You have 309 out of 32710725 that take longer than 10.000000 sec. to complete
    Your long_query_time seems to be fine
    
    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/5.6/en/point-in-time-recovery.html
    
    WORKER THREADS
    Current thread_cache_size = 9
    Current threads_cached = 4
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    
    MAX CONNECTIONS
    Current max_connections = 151
    Current threads_connected = 7
    Historic max_used_connections = 83
    The number of used connections is 54% of the configured maximum.
    Your max_connections variable seems to be fine.
    
    INNODB STATUS
    Current InnoDB index space = 7 M
    Current InnoDB data space = 5 M
    Current InnoDB buffer pool free = 74 %
    Current innodb_buffer_pool_size = 128 M
    Depending on how much space your innodb indexes take up it may be safe
    to increase this value to up to 2 / 3 of total system memory
    
    MEMORY USAGE
    Max Memory Ever Allocated : 246 M
    Configured Max Per-thread Buffers : 169 M
    Configured Max Global Buffers : 153 M
    Configured Max Memory Limit : 322 M
    Physical Memory : 6.00 G
    Max memory limit seem to be within acceptable norms
    
    KEY BUFFER
    Current MyISAM index space = 529 M
    Current key_buffer_size = 8 M
    Key cache miss rate is 1 : 215
    Key buffer free ratio = 0 %
    You could increase key_buffer_size
    It is safe to raise this up to 1/4 of total system memory;
    assuming this is a dedicated database server.
    
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 1 M
    Current query_cache_used = 16 K
    Current query_cache_limit = 1 M
    Current Query cache Memory fill ratio = 1.64 %
    Current query_cache_min_res_unit = 4 K
    Your query_cache_size seems to be too high.
    Perhaps you can use these resources elsewhere
    MySQL won't cache query results that are larger than query_cache_limit in size
    
    SORT OPERATIONS
    Current sort_buffer_size = 256 K
    Current read_rnd_buffer_size = 256 K
    Sort buffer seems to be fine
    
    JOINS
    Current join_buffer_size = 260.00 K
    You have had 15288 queries where a join could not use an index properly
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    If you are unable to optimize your queries you may want to increase your
    join_buffer_size to accommodate larger joins in one pass.
    
    Note! This script will still suggest raising the join_buffer_size when
    ANY joins not using indexes are found.
    
    OPEN FILES LIMIT
    Current open_files_limit = 10000 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine
    
    TABLE CACHE
    Current table_open_cache = 2000 tables
    Current table_definition_cache = 1400 tables
    You have a total of 1193 tables
    You have 1581 open tables.
    The table_cache value seems to be fine
    
    TEMP TABLES
    Current max_heap_table_size = 16 M
    Current tmp_table_size = 16 M
    Of 363784 temp tables, 1% were created on disk
    Created disk tmp tables ratio seems fine
    
    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 34 : 1
    read_buffer_size seems to be fine
    
    TABLE LOCKING
    Current Lock Wait ratio = 1 : 1370
    You may benefit from selective use of InnoDB.
    If you have long running SELECT's against MyISAM tables and perform
    frequent updates consider setting 'low_priority_updates=1'
    If you have a high concurrency of inserts on Dynamic row-length tables
    consider setting 'concurrent_insert=ALWAYS'.
    
    Thanks in advance for your Help.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    While you await user-feedback on the MySQL optimization, I wanted to note that the following thread is useful if you want to troubleshoot high loads or CPU usage:

    Troubleshooting High Loads On Linux Systems

    Thank you.
     
Loading...

Share This Page