wrender

Well-Known Member
Sep 29, 2007
69
3
58
We have a server with approx 120 websites, 8 Processor Cores, 42GB of Ram, Intel 910 SSD.

We have 3GB of INNODB databases (10481 Tables). We converted from MYISAM to improve row locking/updating so there are no MYISAM tables.

Would anyone be able to provide input on what we should set the table_open_cache and table_definition_cache to with MySQL 5.6? I have used both mysqltuner.pl, and tuning-primer.sh but they don't always seem to provide good information, even after 24 hours of mysql uptime. For example mysqltuner.pl always says to increase the table_open_cache which doesn't seem accurate. I am concerned we have set them too high as there are some blog posts about scalability.

Also, we have set vm.swappiness=10 as recommended by RedHat here: https://access.redhat.com/documenta...rformance_Tuning_Guide/s-memory-tunables.html . I am also wondering if it should be just set to 0, but I have read here it should not be with newer kernels: OOM relation to vm.swappiness=0 in new kernel; kills MySQL server process It does appear that MySQL starts swapping a lot after about 8hrs, and setting to 10 did seem to improve this a bit, but it still does start swapping a bit.

Thanks in advance!

Here is our current my.cnf:
Code:
[mysqld_safe]
log-error="/var/log/mysqld.log"

[mysqld]
socket="/var/lib/mysql/mysql.sock"
max_allowed_packet=268435456
max_connections=150
open_files_limit=23000

#InnoDB Settings
default-storage-engine=InnoDB
innodb_file_per_table=1
innodb_buffer_pool_size=4G
innodb_log_file_size=192M
innodb_flush_method=O_DIRECT

#Query Cache Settings
query_cache_size=96M
query_cache_type=1

join_buffer_size=1M

tmp_table_size=64M
max_heap_table_size=64M

table_open_cache=17000
table_definition_cache=12000
 

kernow

Well-Known Member
Jul 23, 2004
1,020
62
178
cPanel Access Level
Root Administrator
......but they don't always seem to provide good information, even after 24 hours of mysql uptime.
This just isn't long enough. You should wait at least 48 hours before making further edits.
I would trust tuning-primer rather than mysqltuner.pl with mysql 5.6
And if you have not given control of innodb_buffer_pool_size to cpanel then you might want to double innodb_buffer_pool_size to 8GB. But I say again, make edits, wait 48 hours before running the tuning script again and making further changes. It can take a week before you get the optimum settings.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

I've moved this thread to our "Optimization" forum.

Thank you.
 

wrender

Well-Known Member
Sep 29, 2007
69
3
58
I've finally let MySQL run for more than 2 days. If anyone can provide some recommendations on our configuration it would be greatly appreciated!

I found that if I increase the query cache, it actually ends up slowing things down after about a day. It seems to cause issues with mysql inserts becoming very slow. For this reason I am really hesitant to increase any values that are recommended by the tuning scripts. Also, it appears as though MySQLTuner-perl always says to increase values for Table Cache.

Also, noticed that MariaDB is now included with the new cPanel 11.48.x. Once it is moved to "release" tier we will most likely upgrade to that as have heard that it has many performance improvements. Had a hard time finding documentation on what performance improvements MariaDB provides. Sounds like maybe it only provides performance improvements on systems that have over 16 processor cores and handles threads better?

Here is my running configuration:

Code:
[mysqld_safe]
log-error="/var/log/mysqld.log"

[mysqld]
socket="/var/lib/mysql/mysql.sock"
max_allowed_packet=268435456
max_connections=150
open_files_limit=140000

#InnoDB Settings
default-storage-engine=InnoDB
innodb_file_per_table=1
innodb_buffer_pool_size=8G
innodb_flush_method=O_DIRECT

#Query Cache Settings
query_cache_size=16M
query_cache_type=1

join_buffer_size=1M

tmp_table_size=32M
max_heap_table_size=32M

table_open_cache=70000
table_definition_cache=12000
Here is tuning-primer output after running for over 48 hours:

Code:
MySQL Version 5.6.22 x86_64

Uptime = 2 days 16 hrs 18 min 34 sec
Avg. qps = 137
Total Questions = 31749524
Threads Connected = 12

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 0 out of 31749545 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 = 6
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 150
Current threads_connected = 13
Historic max_used_connections = 37
The number of used connections is 24% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 933 M
Current InnoDB data space = 2.78 G
Current InnoDB buffer pool free = 49 %
Current innodb_buffer_pool_size = 8.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 : 8.10 G
Configured Max Per-thread Buffers : 281 M
Configured Max Global Buffers : 8.03 G
Configured Max Memory Limit : 8.31 G
Physical Memory : 41.13 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 15 M
Current key_buffer_size = 8 M
Key cache miss rate is 1 : 475
Key buffer free ratio = 71 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 14 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 90.14 %
Current query_cache_min_res_unit = 4 K
However, 3694046 queries have been removed from the query cache due to lack of m                                                   emory
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 = 1.00 M
You have had 10063 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 = 140160 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 = 70000 tables
Current table_definition_cache = 12000 tables
You have a total of 10740 tables
You have 10816 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 32 M
Current tmp_table_size = 32 M
Of 753565 temp tables, 29% 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 = 16 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 280663
Your table locking seems to be fine
Here is output from MySQLTuner-perl

Code:
 >>  MySQLTuner 1.4.0 - Major Hayden <[email protected]>
 >>  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.22
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 63M (Tables: 109)
[--] Data in InnoDB tables: 2G (Tables: 10533)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 52)
[--] Data in MEMORY tables: 0B (Tables: 17)
[!!] Total fragmented tables: 229

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 2d 16h 28m 29s (31M q [137.107 qps], 250K conn, TX: 118B, RX: 16B)
[--] Reads / Writes: 80% / 20%
[--] Total buffers: 8.1G global + 1.9M per thread (150 max threads)
[OK] Maximum possible memory usage: 8.3G (20% of installed RAM)
[OK] Slow queries: 0% (0/31M)
[OK] Highest usage of available connections: 24% (37/150)
[OK] Key buffer size / total MyISAM indexes: 8.0M/15.7M
[OK] Key buffer hit rate: 99.8% (6M cached / 13K reads)
[OK] Query cache efficiency: 66.6% (18M cached / 27M selects)
[!!] Query cache prunes per day: 1379018
[OK] Sorts requiring temporary tables: 0% (211 temp sorts / 801K sorts)
[!!] Joins performed without indexes: 10111
[!!] Temporary tables created on disk: 41% (315K on disk / 755K total)
[OK] Thread cache hit rate: 99% (1K created / 250K connections)
[!!] Table cache hit rate: 0% (10K open / 8M opened)
[OK] Open file limit used: 0% (272/140K)
[OK] Table locks acquired immediately: 99% (13M immediate / 13M locks)
[OK] InnoDB buffer pool / data size: 8.0G/2.8G
[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
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    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 (> 16M)
    join_buffer_size (> 1.0M, or always use indexes with joins)
    tmp_table_size (> 32M)
    max_heap_table_size (> 32M)
    table_open_cache (> 70000)
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Also, noticed that MariaDB is now included with the new cPanel 11.48.x. Once it is moved to "release" tier we will most likely upgrade to that as have heard that it has many performance improvements.
Hello :)

cPanel version 11.48 is now available on the "Release" build tier if you want to update to this version.

Thank you.
 

wrender

Well-Known Member
Sep 29, 2007
69
3
58
Came across an issue when upgrading to MariaDB via WHM interface:

"Your server’s MySQL/MariaDB MAX_USER_CONNECTIONS value is larger then 2147483647"

I've tried adding "max_user_connections=30" in my.cnf and restarting, but still will not load.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463