Skip to content

When a cPanel host needs MariaDB tuning vs more iron

How to tell whether your cPanel database pain is configuration-shaped or hardware-shaped, and the order in which to attack each.

The “the database is slow” ticket is usually one of two problems wearing the same disguise: MariaDB configured for the wrong workload size, or a server that’s genuinely out of capacity. Throwing hardware at the first wastes money; tuning the second wastes the weekend. The diagnostic order matters.

The trade-off

Tuning is cheap and reversible. Hardware upgrades are expensive and partially reversible. Always tune first — but only after measuring, not by copy-pasting my.cnf snippets from a 2014 blog post written for a different MariaDB version on different hardware.

How to verify — the diagnostic order

  1. Look at the slow query log first. Enable it if it’s not on: slow_query_log=1, long_query_time=2, log_queries_not_using_indexes=1. Run for 24 hours of normal traffic. One missing index on one busy table is usually the entire problem.
  2. Check SHOW ENGINE INNODB STATUS\G for buffer pool hit ratio, wait events, and lock contention. Buffer pool hit ratio under 99% on a working set that should fit in RAM = under-sized innodb_buffer_pool_size.
  3. Look at mysqltuner.pl output. Not gospel, but it flags obvious misconfigurations — buffer pool sized to default 128MB on a 64GB box, max connections set to 1000 with no thread pool, MyISAM tables when everything should be InnoDB.
  4. Check disk I/O against database load. iostat -x 5 while traffic is real. If %util on the data disk is sustained above 80%, you’re disk-bound — tune harder or move to faster storage.
  5. Check per-account query patterns. WHM > Manage MySQL Profiles. One account running SELECT * FROM wp_options without autoload indexed is a different problem from “we need more RAM”.

What to do

In order, stopping when the problem goes away:

  1. Add the missing indexes the slow query log identified.
  2. Set innodb_buffer_pool_size to roughly 50-70% of dedicated database RAM (less if MySQL shares the box with PHP-FPM and other tenants).
  3. Set innodb_log_file_size to roughly 25% of buffer pool, capped at 4GB.
  4. Set innodb_flush_method=O_DIRECT on Linux with direct I/O — avoids double-buffering between MariaDB and the OS.
  5. Confirm query_cache_type=OFF on MariaDB 10.6+ — the query cache is a known contention point at any concurrency.
  6. If buffer pool hit ratio is still under 99% with the working set fully cached, you actually do need more RAM. Add iron.
  7. If queries are well-indexed and the buffer pool is large enough but disk wait dominates, you actually do need faster disk. Move to NVMe.

For dense shared hosting, also consider splitting MariaDB to a dedicated database host. Stack Harbor handles this diagnostic order as part of WHM server management.