MySQL Optimization Help for 72GB server
Hi
I need to optimize mysql to get the benefit from available ram. I am also interested in using ramdrive/tmpfs for temporary tables created on disk.
my.cnf
mysqltuner.pl
tuning-primer
[mysqld]
innodb_file_per_table = 1
local-infile=0
query_cache_size = 128M
query_cache_type = 1
thread_cache_size = 4
query_cache_limit = 10M
open_files_limit = 3544
tmp_table_size = 32M
max_heap_table_size = 32M
table_cache = 1k
mysqltuner.pl
>> MySQLTuner 1.2.0 - Major Hayden
>> 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.5.35-cll
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 1G (Tables: 2688)
[--] Data in InnoDB tables: 50M (Tables: 635)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[--] Data in MEMORY tables: 0B (Tables: 9)
[!!] Total fragmented tables: 54
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 3d 7h 0m 15s (56M q [198.937 qps], 1M conn, TX: 12042B, RX: 7B)
[--] Reads / Writes: 96% / 4%
[--] Total buffers: 312.0M global + 2.8M per thread (151 max threads)
[OK] Maximum possible memory usage: 727.2M (1% of installed RAM)
[OK] Slow queries: 0% (491/56M)
[!!] Highest connection usage: 100% (152/151)
[OK] Key buffer size / total MyISAM indexes: 8.0M/438.4M
[OK] Key buffer hit rate: 99.5% (3B cached / 16M reads)
[OK] Query cache efficiency: 58.2% (29M cached / 50M selects)
[!!] Query cache prunes per day: 4039839
[OK] Sorts requiring temporary tables: 9% (350K temp sorts / 3M sorts)
[!!] Temporary tables created on disk: 44% (1M on disk / 2M total)
[OK] Thread cache hit rate: 92% (90K created / 1M connections)
[!!] Table cache hit rate: 0% (1K open / 121K opened)
[OK] Open file limit used: 55% (1K/3K)
[OK] Table locks acquired immediately: 99% (25M immediate / 25M locks)
[OK] InnoDB data size / buffer pool: 50.2M/128.0M
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
Reduce or eliminate persistent connections to reduce connection usage
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
max_connections (> 151)
wait_timeout (< 28800)
interactive_timeout (< 28800)
query_cache_size (> 128M)
tmp_table_size (> 32M)
max_heap_table_size (> 32M)
table_cache (> 1024)
tuning-primer
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.5.35-cll x86_64
Uptime = 3 days 6 hrs 59 min 27 sec
Avg. qps = 198
Total Questions = 56570314
Threads Connected = 5
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.5/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 491 out of 56570336 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.5/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 4
Current threads_cached = 2
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 = 5
Historic max_used_connections = 152
The number of used connections is 100% of the configured maximum.
You should raise max_connections
INNODB STATUS
Current InnoDB index space = 21 M
Current InnoDB data space = 50 M
Current InnoDB buffer pool free = 0 %
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 : 698 M
Configured Max Per-thread Buffers : 415 M
Configured Max Global Buffers : 280 M
Configured Max Memory Limit : 695 M
Physical Memory : 70.65 G
Max memory limit seem to be within acceptable norms
KEY BUFFER
Current MyISAM index space = 438 M
Current key_buffer_size = 8 M
Key cache miss rate is 1 : 196
Key buffer free ratio = 73 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 116 M
Current query_cache_limit = 10 M
Current Query cache Memory fill ratio = 91.32 %
Current query_cache_min_res_unit = 4 K
However, 13295265 queries have been removed from the query cache due to lack of memory
Perhaps you should raise query_cache_size
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 132.00 K
You have had 374 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 = 3544 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 = 1024 tables
Current table_definition_cache = 400 tables
You have a total of 3373 tables
You have 1024 open tables.
Current table_cache hit rate is 0%
, while 100% of your table cache is in use
You should probably increase your table_cache
You should probably increase your table_definition_cache value.
TEMP TABLES
Current max_heap_table_size = 32 M
Current tmp_table_size = 32 M
Of 1382889 temp tables, 44% 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 = 128 K
Current table scan ratio = 34741 : 1
You have a high ratio of sequential access requests to SELECTs
You may benefit from raising read_buffer_size and/or improving your use of index es.
TABLE LOCKING
Current Lock Wait ratio = 1 : 132
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'.
-
Hello, If you are using MySQL 5.6, we strongly no longer recommend mysqltuner to be used. Please review the following thread I just posted on this: Warning on using mysqltuner for MySQL 5.6 0 -
I am using mysql version 5.5.35-cll 0 -
[mysqld] innodb_file_per_table = 1 local-infile=0 join_buffer_size=2M sort_buffer_size=256K query_cache_size = 128M query_cache_type = 1 query_cache_limit = 1M thread_cache_size = 16 open_files_limit = 20000 tmp_table_size = 32M max_heap_table_size = 32M table_cache = 6k key_buffer_size = 700M slow_query_log=1 slow_query_log_file=mysql-slow.log long_query_time=0.1 0 -
updated and restarted. will update after 234 hours. Any help on using ram for temp. 0 -
add tmpdir=/dev/shm the simplest way 0 -
here is an update >> MySQLTuner 1.2.0 - Major Hayden >> 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.5.35-cll [OK] Operating on 64-bit architecture -------- Storage Engine Statistics ------------------------------------------- [--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster [--] Data in MyISAM tables: 2G (Tables: 3208) [--] Data in InnoDB tables: 61M (Tables: 1213) [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17) [--] Data in MEMORY tables: 0B (Tables: 26) [!!] Total fragmented tables: 68 -------- Security Recommendations ------------------------------------------- [OK] All database users have passwords assigned -------- Performance Metrics ------------------------------------------------- [--] Up for: 21h 27m 33s (15M q [196.778 qps], 358K conn, TX: 3048B, RX: 1B) [--] Reads / Writes: 95% / 5% [--] Total buffers: 1004.0M global + 2.9M per thread (300 max threads) [OK] Maximum possible memory usage: 1.8G (2% of installed RAM) [!!] Slow queries: 15% (2M/15M) [OK] Highest usage of available connections: 12% (36/300) [OK] Key buffer size / total MyISAM indexes: 700.0M/473.5M [OK] Key buffer hit rate: 100.0% (661M cached / 46K reads) [OK] Query cache efficiency: 66.0% (8M cached / 13M selects) [!!] Query cache prunes per day: 2448529 [!!] Sorts requiring temporary tables: 54% (443K temp sorts / 807K sorts) [!!] Joins performed without indexes: 2594 [!!] Temporary tables created on disk: 44% (286K on disk / 637K total) [OK] Thread cache hit rate: 99% (178 created / 358K connections) [OK] Table cache hit rate: 99% (4K open / 4K opened) [OK] Open file limit used: 33% (6K/20K) [OK] Table locks acquired immediately: 99% (5M immediate / 5M locks) [OK] InnoDB data size / buffer pool: 61.9M/128.0M -------- Recommendations ----------------------------------------------------- General recommendations: Run OPTIMIZE TABLE to defragment tables for better performance MySQL started within last 24 hours - recommendations may be inaccurate 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 without LIMIT clauses Variables to adjust: query_cache_size (> 128M) sort_buffer_size (> 256K) read_rnd_buffer_size (> 256K) join_buffer_size (> 2.0M, or always use indexes with joins) tmp_table_size (> 32M) max_heap_table_size (> 32M)
-- MYSQL PERFORMANCE TUNING PRIMER -- - By: Matthew Montgomery - MySQL Version 5.5.35-cll x86_64 Uptime = 0 days 21 hrs 30 min 28 sec Avg. qps = 196 Total Questions = 15243882 Threads Connected = 9 Warning: Server has not been running for at least 48hrs. It may not be safe to use these recommendations To find out more information on how each of these runtime variables effects performance visit: http://dev.mysql.com/doc/refman/5.5/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 enabled. Current long_query_time = 0.100000 sec. You have 2391899 out of 15243904 that take longer than 0.100000 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.5/en/point-in-time-recovery.html WORKER THREADS Current thread_cache_size = 16 Current threads_cached = 8 Current threads_per_sec = 0 Historic threads_per_sec = 0 Your thread_cache_size is fine MAX CONNECTIONS Current max_connections = 300 Current threads_connected = 9 Historic max_used_connections = 36 The number of used connections is 12% of the configured maximum. Your max_connections variable seems to be fine. INNODB STATUS Current InnoDB index space = 39 M Current InnoDB data space = 61 M Current InnoDB buffer pool free = 0 % 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 : 1.05 G Configured Max Per-thread Buffers : 862 M Configured Max Global Buffers : 972 M Configured Max Memory Limit : 1.79 G Physical Memory : 70.65 G Max memory limit seem to be within acceptable norms KEY BUFFER Current MyISAM index space = 473 M Current key_buffer_size = 700 M Key cache miss rate is 1 : 14274 Key buffer free ratio = 73 % Your key_buffer_size seems to be too high. Perhaps you can use these resources elsewhere QUERY CACHE Query cache is enabled Current query_cache_size = 128 M Current query_cache_used = 120 M Current query_cache_limit = 1 M Current Query cache Memory fill ratio = 94.29 % Current query_cache_min_res_unit = 4 K However, 2194760 queries have been removed from the query cache due to lack of memory Perhaps you should raise query_cache_size 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 = 2.00 M You have had 1318 queries where a join could not use an index properly You have had 1287 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 = 20000 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 = 6144 tables Current table_definition_cache = 400 tables You have a total of 4488 tables You have 4668 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 = 32 M Current tmp_table_size = 32 M Of 352108 temp tables, 44% 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 = 128 K Current table scan ratio = 39578 : 1 You have a high ratio of sequential access requests to SELECTs You may benefit from raising read_buffer_size and/or improving your use of indexes. TABLE LOCKING Current Lock Wait ratio = 1 : 191 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'.0 -
Based on the results I can tell that you got some not optimized code/script, is it some custom code ? or maybe some CMS with a lot of non optimized third party plugins the output is of course better, now MyISAM buffer fits in memory [OK] Key buffer size / total MyISAM indexes: 700.0M/473.5M so thats good, improvement should be significant for MyiSAM table queries 0 -
its a shared server so I don't have control over the queries but still I am planing to contact some clients who are major contributor to these queries. Do you think there is more room to trade of between ram/cpu. I have plenty of ram available which I can use. Server Dual Intel(R) Xeon(R) CPU E5620 @ 2.40GHz (16 cores) 72 GB Ram 8x1TB HDD in RAID 10. Server load Peaks at 5-6 SAR CPU %user %nice %system %iowait %steal %idle Average: all 21.07 0.18 4.29 0.08 0.00 74.39 free -m total used free shared buffers cached Mem: 72346 35896 36450 0 1115 28230 -/+ buffers/cache: 6549 65796 Swap: 16171 205 15966 0 -
you can increase 2 main buffers for the future when data grows key_buffer_size = 5G innodb_buffer_pool_size = 5G except that, nothing much else to do if you can't optimize the queries anyway current changes should make significant improvements, especially on MyISAM tables 0
Please sign in to leave a comment.
Comments
9 comments