Little Tuning Help Please

Dradden45

Active Member
Sep 7, 2012
37
2
8
cPanel Access Level
Root Administrator
Server has been running for a week and time to try and tune Mysql (MariaDB) up some.

Server Specs:

7GB Ram
2 cpu
NVME drives

Server runs Litespeed and all sites on it are WordPress and utilize LsCache + LSMCD as an object cache.

Current configs for sql:

Code:
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[mysqld]
log-error=/var/lib/mysql/s05.thedomain.ca.err
performance-schema=0
innodb_file_per_table=1
max_allowed_packet=268435456
open_files_limit=10000
SQL Tuner Output:


Code:
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in MyISAM tables: 41.3M (Tables: 355)
[--] Data in InnoDB tables: 16.5M (Tables: 67)
[OK] Total fragmented tables: 0
 
-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
 
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.
 
-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION
 
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 4d 17h 45m 0s (2M q [6.225 qps], 115K conn, TX: 8G, RX: 520M)
[--] Reads / Writes: 67% / 33%
[--] Binary logging is disabled
[--] Physical Memory     : 6.5G
[--] Max MySQL memory    : 38.6G
[--] Other process memory: 0B
[--] Total buffers: 417.0M global + 258.9M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 4.2G (64.70% of installed RAM)
[!!] Maximum possible memory usage: 38.6G (594.40% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/2M)
[OK] Highest usage of available connections: 9% (15/151)
[OK] Aborted connections: 0.11%  (127/115076)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 1M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 171K sorts)
[!!] Joins performed without indexes: 9337
[!!] Temporary tables created on disk: 41% (173K on disk / 422K total)
[OK] Thread cache hit rate: 99% (15 created / 115K connections)
[OK] Table cache hit rate: 76% (597 open / 777 opened)
[!!] table_definition_cache(400) is lower than number of tables(687)
[OK] Open file limit used: 8% (804/10K)
[OK] Table locks acquired immediately: 99% (945K immediate / 945K locks)
 
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema is installed.
 
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 2 thread(s).
[--] Using default value is good enough for your version (10.3.22-MariaDB)
 
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 22.1% (29M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/6.9M
[OK] Read Key buffer hit rate: 100.0% (7M cached / 1K reads)
[!!] Write Key buffer hit rate: 64.0% (654K cached / 419K writes)
 
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 128.0M/16.5M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal to 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (15199748 hits/ 15200315 total)
[!!] InnoDB Write Log efficiency: 69.98% (331283 hits/ 473377 total)
[OK] InnoDB log waits: 0.00% (0 waits / 142094 writes)
 
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[!!] Aria pagecache hit rate: 88.7% (1M cached / 158K reads)
 
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
 
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
 
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
 
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server
 
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/lib/mysql/s05.thedomain.ca.err file
    Control error line(s) into /var/lib/mysql/s05.thedomain.ca.err file
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Performance schema should be activated for better diagnostics
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_definition_cache(400) > 687 or -1 (autosizing if supported)
    performance_schema = ON enable PFS
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
Been 2 years at least since I dove into tuning a sql server so have forgotten near everything. I do remember changing adding a select few configs to do with logs could cause the server not to start back up, because of format change I think...

I have a lot of reading and catching up to do and any help is appreciated :) This server will get an upgrade in the near future as well and its ram will near double.
 

rackaid

Well-Known Member
Jan 18, 2003
89
27
168
Jacksonville, FL
cPanel Access Level
DataCenter Provider
Before diving into tuning MySQL, what makes you think it is a bottleneck? From your stats, I do not see any lock wait condition and buffer hit rates are high. I doubt you will see much improvement by adjusting your variables.

I would start with adjusting the slow query time setting and log slow queries.

Also, not sure why the system is calculating such high memory usage. Do you have have a high sort/read/join buffer sizes?
 

Dradden45

Active Member
Sep 7, 2012
37
2
8
cPanel Access Level
Root Administrator
Right now it isn't a bottleneck, I was more after preventing it from becoming one if possible. There will be a bunch more sites and some woo-commerce stores being added in the near future.

Also, not sure why the system is calculating such high memory usage. Do you have have a high sort/read/join buffer sizes?
I believe these must be whatever MariaDB has as a default? There is nothing about these in the my.cnf, the only things listed there are what I listed in my original post.
 

rackaid

Well-Known Member
Jan 18, 2003
89
27
168
Jacksonville, FL
cPanel Access Level
DataCenter Provider
The script says you have 258.9M of memory configured in per-thread settings. I wonder if this is not a math error and this should be 258KB per thread.

Regardless, I would not rely too much on these tools. One of the issues is that they are more designed for stand-alone database systems powering single applications/tenants.

For example, the MyISAM index calculation is based on all MyISAM indexes. However, on a shared hosting system, you may find a lot of dormant databases. So the total MyISAM index size is not reflective of the actual indexes in use. I've seen people crank up their key_buffer to GBs but in fact only a handful of databases are in use at once.

Pay attention to your cache hit rates and table locks. These will be the first items to show declines as you add more sites.

Another common issue is that these scripts (and many tuning tutorials) suggest using InnoDB over MyISAM. However, the default on cPanel is MyISAM.

(MyISAM is often better for backup/recover on shared hosting, but that is another matter).

With MyISAM and the fact that most web apps are read intensive, enabling the query_cache can be beneficial.

So if you were to tune one thing, I would enable the query_cache and set it to about 16MB.

Code:
query_cache_type = 1
query_cache_size = 32M
The query cache keeps recent SELECT statements in ram. With apps like shopping carts, discussion forums, etc, there are often many queries that can be cached. Enable the cache usually improves page response times though you may not see any appreciable improvements server side.

Lastly, install the Munin plugin so you have more data to analyze as you begin to add more sites.
 
  • Like
Reactions: Dradden45

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,304
1,252
313
Houston
Beyond the great advice provided by @rackaid I'd suggest enlisting the assistance of a qualified system administrator. If you don't have one you might find one here: System Administration Services
 

Dradden45

Active Member
Sep 7, 2012
37
2
8
cPanel Access Level
Root Administrator
@rackaid
Thanks that is good information. I have a basic tune in it now and cache hit rate is better then it was, I think it is fine for now. I always install munin as part of server setup gives good information. To boost my dive back into this I am taking a couple Mysql / MaraiDB DBA courses, things are coming back fairly quick.

@cPanelLauren
If I need to rely on a server admin I probably should not be running any servers, I prefer to learn and do myself. But thank you for the advice :)
 
  • Like
Reactions: inteldigital