Optimize MySQL 5.6 (high iowait times since upgrade from 5.1)
Hello,
I've recently upgrade from mysql 5.1 to mysql 5.6 and i've noticed that iowait time has increased since then. I've done some tuning but i still see high iowait from times to times.
System specs:
CPU: Intel(R) Xeon(R) CPU W3565 @ 3.20GHz
RAM: 24GB
HDD: 2x2TB SATA 3 RAID-1
Here is my current configuration
mysqltuner output
Tuning Primer
sar -q output
Any tweaking suggestions are welcomed! Thanks in advance! :)
[mysqld]
max_connections = 100
innodb_buffer_pool_size = 2G
query_cache_size = 512M
query_cache_limit = 2M
join_buffer_size = 4M
tmp_table_size = 64M
max_heap_table_size = 64M
table_definition_cache = 3000
table_open_cache = 12000
innodb_buffer_pool_size = 6G
slow_query_log = 1
slow_query_log_file = /var/log/mysql_slow.log
long_query_time = 5
low_priority_updates=1
concurrent_insert=1
mysqltuner output
>> MySQLTuner 1.3.0 - Major Hayden
>> 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.17-log
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 4G (Tables: 4102)
[--] Data in InnoDB tables: 1G (Tables: 5398)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 52)
[--] Data in MEMORY tables: 2M (Tables: 135)
[!!] Total fragmented tables: 482
-------- Performance Metrics -------------------------------------------------
[--] Up for: 2d 0h 54m 47s (26M q [150.147 qps], 168K conn, TX: 65B, RX: 11B)
[--] Reads / Writes: 73% / 27%
[--] Total buffers: 6.6G global + 7.5M per thread (100 max threads)
[OK] Maximum possible memory usage: 7.3G (31% of installed RAM)
[OK] Slow queries: 0% (91/26M)
[OK] Highest usage of available connections: 13% (13/100)
[OK] Key buffer size / total MyISAM indexes: 32.0M/254.4M
[OK] Key buffer hit rate: 98.0% (17M cached / 350K reads)
[OK] Query cache efficiency: 95.3% (23M cached / 25M selects)
[!!] Query cache prunes per day: 226136
[OK] Sorts requiring temporary tables: 0% (3 temp sorts / 246K sorts)
[!!] Joins performed without indexes: 18737
[OK] Temporary tables created on disk: 23% (127K on disk / 550K total)
[OK] Thread cache hit rate: 99% (13 created / 168K connections)
[!!] Table cache hit rate: 14% (12K open / 83K opened)
[OK] Open file limit used: 23% (8K/36K)
[OK] Table locks acquired immediately: 99% (2M immediate / 2M locks)
[OK] InnoDB buffer pool / data size: 6.0G/1.2G
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Increasing the query_cache size over 128M may reduce 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_size (> 512M) [see warning above]
join_buffer_size (> 4.0M, or always use indexes with joins)
table_open_cache (> 12000)
Tuning Primer
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.6.17-log x86_64
Uptime = 2 days 0 hrs 59 min 40 sec
Avg. qps = 150
Total Questions = 26511441
Threads Connected = 2
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 = 5.000000 sec.
You have 91 out of 26511462 that take longer than 5.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 = 286
Current threads_cached = 11
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 2
Historic max_used_connections = 13
The number of used connections is 13% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 665 M
Current InnoDB data space = 1.25 G
Current InnoDB buffer pool free = 73 %
Current innodb_buffer_pool_size = 6.00 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 : 6.64 G
Configured Max Per-thread Buffers : 750 M
Configured Max Global Buffers : 6.54 G
Configured Max Memory Limit : 7.27 G
Physical Memory : 23.45 G
Max memory limit seem to be within acceptable norms
KEY BUFFER
Current MyISAM index space = 254 M
Current key_buffer_size = 32 M
Key cache miss rate is 1 : 50
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 = 512 M
Current query_cache_used = 389 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 76.09 %
Current query_cache_min_res_unit = 4 K
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 = 4.00 M
You have had 18263 queries where a join could not use an index properly
You have had 500 joins without keys that check for key usage after each row
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
OPEN FILES LIMIT
Current open_files_limit = 36936 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 = 12000 tables
Current table_definition_cache = 3000 tables
You have a total of 9716 tables
You have 12000 open tables.
Current table_cache hit rate is 14%
, 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 = 64 M
Current tmp_table_size = 64 M
Of 423551 temp tables, 23% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 282 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 21583
Your table locking seems to be fine
sar -q output
12:00:01 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
12:10:01 AM 3 342 0.94 0.90 0.82
12:20:01 AM 2 345 3.58 2.74 1.70
12:30:01 AM 1 349 3.30 3.85 2.84
12:40:02 AM 1 352 4.26 4.10 3.34
12:50:01 AM 1 341 3.04 3.46 3.38
01:00:01 AM 3 374 3.95 3.85 3.58
01:10:01 AM 4 361 2.31 2.99 3.27
01:20:01 AM 3 337 2.25 2.66 3.03
01:30:01 AM 2 341 3.53 3.74 3.44
01:40:01 AM 3 368 3.17 3.43 3.45
01:50:01 AM 1 327 2.95 3.54 3.49
02:00:02 AM 2 363 3.71 3.85 3.70
02:10:01 AM 3 350 4.52 3.92 3.78
02:20:01 AM 8 341 3.41 4.07 3.97
02:30:01 AM 2 342 4.57 4.50 4.18
02:40:01 AM 3 352 3.81 4.01 4.06
02:50:01 AM 3 348 3.20 3.49 3.79
03:00:01 AM 4 326 1.83 2.82 3.32
03:10:01 AM 3 334 0.79 1.21 2.22
03:20:01 AM 3 322 1.27 0.80 1.46
03:30:01 AM 3 326 0.45 0.74 1.14
03:40:01 AM 3 326 1.05 0.67 0.85
03:50:01 AM 5 321 0.16 0.35 0.58
04:00:01 AM 5 334 0.65 0.43 0.48
04:10:01 AM 4 334 1.49 1.64 1.17
04:20:01 AM 4 354 2.41 1.85 1.47
04:30:01 AM 5 359 1.95 2.35 1.99
04:40:01 AM 3 335 2.56 2.04 1.94
04:50:01 AM 4 328 1.65 2.08 2.03
05:00:02 AM 1 330 3.57 3.62 2.71
05:10:01 AM 3 342 2.45 2.61 2.58
05:20:01 AM 4 325 2.69 2.20 2.28
05:30:01 AM 3 330 1.79 1.93 2.10
05:40:02 AM 1 327 2.30 2.26 2.26
05:50:01 AM 3 328 3.63 2.77 2.40
06:00:01 AM 3 337 2.14 2.45 2.47
06:10:01 AM 1 335 1.95 2.04 2.24
06:20:01 AM 3 328 1.71 2.02 2.14
06:30:01 AM 6 344 0.65 1.00 1.55
06:40:01 AM 4 328 1.38 0.97 1.20
06:50:01 AM 3 311 0.24 0.55 0.92
07:00:01 AM 4 317 0.58 0.53 0.70
07:10:01 AM 3 336 0.59 0.64 0.69
07:20:01 AM 3 316 0.38 0.69 0.71
07:30:01 AM 3 339 0.50 0.79 0.77
07:40:01 AM 3 330 1.42 1.05 0.90
07:50:01 AM 3 330 1.71 0.94 0.82
08:00:01 AM 3 324 0.63 0.79 0.80
08:10:01 AM 4 348 1.77 1.11 0.89
08:20:01 AM 3 317 0.84 1.26 1.24
08:30:01 AM 4 334 1.24 1.33 1.28
08:40:01 AM 3 344 1.43 1.23 1.20
Any tweaking suggestions are welcomed! Thanks in advance! :)
-
Am no expert in this but will try. First thing I notice is that you have innodb_buffer_pool_size listed twice in your my.cnf innodb_buffer_pool_size = 2G innodb_buffer_pool_size = 6G
Remove one of the above ( probably the 2G line.) I read recently that mysqltuner output should not be used with Mysql >5.5 so you should just work with the tuning-primer script results. Your table cache results says "100% of your table cache is in use" so this definetely needs adjusting along with table_definition_cache. Try increasing both of these by 50% save and restart Mysql and wait 48 hours before running the tuning-primer script again to see the results.0 -
Hello :) You may also want to take a quick look at /var/log/dmesg and /var/log/messages just to rule out any potential hardware issues with your drive. Thank you. 0
Please sign in to leave a comment.
Comments
2 comments