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 optimization

Discussion in 'Workarounds and Optimization' started by cobysan, May 8, 2014.

  1. cobysan

    cobysan Registered

    Joined:
    May 8, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hello,
    Looking into optimize our DB (mysql, mainly isam, 165 tables, 100M rows, 30 GB, queries per second avg: 251.118)

    tuning-primer results -


    Code:
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
    
    MySQL Version 5.1.73-log x86_64
    
    Uptime = 28 days 19 hrs 20 min 26 sec
    Avg. qps = 249
    Total Questions = 621945607
    Threads Connected = 18
    
    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:
    [url=http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html]MySQL :: MySQL 5.1 Reference Manual :: 5.1.4 Server System Variables[/url]
    Visit [url]http://www.mysql.com/products/enterprise/advisors.html[/url]
    for info about MySQL's Enterprise Monitoring and Advisory Service
    
    SLOW QUERIES
    The slow query log is enabled.
    Current long_query_time = 10.000000 sec.
    You have 2592 out of 621945633 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 [url=http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html]MySQL :: MySQL 5.1 Reference Manual :: 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log[/url]
    
    WORKER THREADS
    Current thread_cache_size = 32
    Current threads_cached = 18
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    
    MAX CONNECTIONS
    Current max_connections = 600
    Current threads_connected = 18
    Historic max_used_connections = 390
    The number of used connections is 65% of the configured maximum.
    Your max_connections variable seems to be fine.
    
    INNODB STATUS
    Current InnoDB index space = 1.69 G
    Current InnoDB data space = 2.26 G
    Current InnoDB buffer pool free = 0 %
    Current innodb_buffer_pool_size = 1.50 G
    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 : 12.93 G
    Configured Max Per-thread Buffers : 14.28 G
    Configured Max Global Buffers : 3.65 G
    Configured Max Memory Limit : 17.93 G
    Physical Memory : 15.57 G
    
    Max memory limit exceeds 90% of physical memory
    
    KEY BUFFER
    Current MyISAM index space = 6.44 G
    Current key_buffer_size = 2.00 G
    Key cache miss rate is 1 : 390
    Key buffer free ratio = 66 %
    Your key_buffer_size seems to be fine
    
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 156 M
    Current query_cache_used = 31 M
    Current query_cache_limit = 1 M
    Current Query cache Memory fill ratio = 20.46 %
    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 = 8 M
    Current read_rnd_buffer_size = 8 M
    Sort buffer seems to be fine
    
    JOINS
    Current join_buffer_size = 132.00 K
    You have had 7185 queries where a join could not use an index properly
    You have had 46 joins without keys that check for key usage after each row
    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 = 8802 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 = 4096 tables
    Current table_definition_cache = 512 tables
    You have a total of 519 tables
    You have 710 open tables.
    The table_cache value seems to be fine
    You should probably increase your table_definition_cache value.
    
    TEMP TABLES
    Current max_heap_table_size = 512 M
    Current tmp_table_size = 512 M
    Of 16375424 temp tables, 25% were created on disk
    Perhaps you should increase your tmp_table_size and/or max_heap_table_size
    to reduce the number of disk-based temporary tables
    Note! BLOB and TEXT columns are not allow in memory tables.
    If you are using these columns raising these values might not impact your
    ratio of on disk temp tables.
    
    TABLE SCANS
    Current read_buffer_size = 8 M
    Current table scan ratio = 18 : 1
    read_buffer_size seems to be fine
    
    TABLE LOCKING
    Current Lock Wait ratio = 1 : 96
    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=2'.
    
    mysqltuner
    
    >>  MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
     >>  Bug reports, feature requests, and downloads at [url=http://mysqltuner.com/]MySQLTuner-perl by major[/url]
     >>  Run with '--help' for additional options and output filtering
    
    -------- General Statistics --------------------------------------------------
    [--] Skipped version check for MySQLTuner script
    [OK] Currently running supported MySQL version 5.1.73-log
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 25G (Tables: 475)
    [--] Data in InnoDB tables: 2G (Tables: 21)
    [!!] Total fragmented tables: 55
    
    - Removed -
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 28d 19h 40m 22s (622M q [249.897 qps], 18M conn, TX: 416B, RX: 123B)
    [--] Reads / Writes: 84% / 16%
    [--] Total buffers: 4.2G global + 24.4M per thread (600 max threads)
    [!!] Maximum possible memory usage: 18.4G (118% of installed RAM)
    [OK] Slow queries: 0% (2K/622M)
    [OK] Highest usage of available connections: 65% (390/600)
    [OK] Key buffer size / total MyISAM indexes: 2.0G/6.4G
    [OK] Key buffer hit rate: 99.7% (42B cached / 108M reads)
    [OK] Query cache efficiency: 32.6% (169M cached / 519M selects)
    [!!] Query cache prunes per day: 16985
    [OK] Sorts requiring temporary tables: 0% (22K temp sorts / 10M sorts)
    [!!] Joins performed without indexes: 7245
    [OK] Temporary tables created on disk: 25% (5M on disk / 22M total)
    [OK] Thread cache hit rate: 99% (24K created / 18M connections)
    [!!] Table cache hit rate: 0% (600 open / 414K opened)
    [OK] Open file limit used: 12% (1K/8K)
    [OK] Table locks acquired immediately: 98% (437M immediate / 441M locks)
    [!!] InnoDB data size / buffer pool: 2.3G/1.5G
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Reduce your overall MySQL memory footprint for system stability
        Increasing the query_cache size over 128M may reduce performance
        Adjust your join queries to always utilize indexes
        Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
      *** MySQL's maximum memory usage is dangerously high ***
      *** Add RAM before increasing MySQL buffer variables ***
        query_cache_size (> 156M) [see warning above]
        join_buffer_size (> 128.0K, or always use indexes with joins)
        table_cache (> 4096)
        innodb_buffer_pool_size (>= 2G)
    Any help will be greatly appreciated !

    Thank you
     
    #1 cobysan, May 8, 2014
    Last edited by a moderator: May 8, 2014
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    650
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. thinkbot

    thinkbot Well-Known Member

    Joined:
    Oct 30, 2012
    Messages:
    326
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    can you run mysqltuner.pl and post the output
    plus, add contents of my.cnf

    - - - Updated - - -

    innodb_buffer_pool_size= 2.5G
    max_connections = 400

    sort_buffer_size=256K
    read_buffer_size=128K
    read_rnd_buffer_size=256K

    and restart
     
  4. cobysan

    cobysan Registered

    Joined:
    May 8, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    hi,

    don't you think these are too low values for the buffers ?

    our db server is AMD Dual x8 Opteron 6128, 8GB RAM, CentOs 6 - 64Bit

    current my.cnf -
    max_connections = 600
    safe-show-database
    key_buffer = 2G
    max_allowed_packet = 64M
    table_cache = 4096
    sort_buffer_size = 8M
    read_buffer_size = 8M
    read_rnd_buffer_size = 8M
    myisam_sort_buffer_size = 64M
    query_cache_size = 156M
    tmp_table_size = 512M
    max_heap_table_size = 512M
    thread_cache_size = 32
    wait_timeout = 120
    connect_timeout = 10
    interactive_timeout = 600
    innodb_buffer_pool_size = 1536M

    Thank you for your help
     
  5. cobysan

    cobysan Registered

    Joined:
    May 8, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi
    Your suggestion works great ! thank you so much -

    New mysqltuner results


    Code:
     >>  MySQLTuner 1.2.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
    
    -------- General Statistics --------------------------------------------------
    [--] Skipped version check for MySQLTuner script
    [OK] Currently running supported MySQL version 5.1.73-log
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 26G (Tables: 476)
    [--] Data in InnoDB tables: 2G (Tables: 22)
    [!!] Total fragmented tables: 42
    
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 3d 14h 45m 44s (80M q [259.191 qps], 2M conn, TX: 49B, RX: 16B)
    [--] Reads / Writes: 82% / 18%
    [--] Total buffers: 5.2G global + 1.0M per thread (400 max threads)
    [OK] Maximum possible memory usage: 5.5G (35% of installed RAM)
    [OK] Slow queries: 0% (99/80M)
    [!!] Highest connection usage: 88%  (354/400)
    [OK] Key buffer size / total MyISAM indexes: 2.0G/6.1G
    [OK] Key buffer hit rate: 99.7% (4B cached / 12M reads)
    [OK] Query cache efficiency: 30.4% (20M cached / 66M selects)
    [!!] Query cache prunes per day: 53194
    [OK] Sorts requiring temporary tables: 8% (124K temp sorts / 1M sorts)
    [OK] Temporary tables created on disk: 25% (815K on disk / 3M total)
    [OK] Thread cache hit rate: 99% (2K created / 2M connections)
    [!!] Table cache hit rate: 1% (680 open / 51K opened)
    [OK] Open file limit used: 13% (1K/8K)
    [OK] Table locks acquired immediately: 98% (56M immediate / 57M locks)
    [OK] InnoDB data size / buffer pool: 2.0G/2.5G
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Reduce or eliminate persistent connections to reduce connection usage
        Increasing the query_cache size over 128M may reduce performance
        Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
        max_connections (> 400)
        wait_timeout (< 120)
        interactive_timeout (< 400)
        query_cache_size (> 156M) [see warning above]
        table_cache (> 4096)
    thank you
    Coby
     
Loading...

Share This Page