Skip to content

MySQL Governor — DB-side throttling for shared cPanel hosts

MySQL Governor limits per-account database resource use on a shared cPanel host, so one tenant's slow query does not freeze the whole MySQL instance.

LVE protects the host’s CPU and memory from a runaway PHP tenant, but it does nothing for MySQL — which runs as a single daemon outside the LVE cages. One tenant’s missing index can pin the MySQL CPU and slow every other tenant on the box. CloudLinux MySQL Governor is the missing piece: it tracks per-account database usage and throttles queries when one tenant exceeds its allowance. We turn it on by default on every multi-tenant cPanel host.

What’s happening

MySQL Governor identifies each query by the connecting cPanel user (via the MySQL user → cPanel user mapping), aggregates resource use, and applies four limits: CPU%, read IO, write IO, and concurrent connections. When a tenant exceeds the limit, Governor either slows new query acceptance or kills the offending query, depending on policy. Critically, it logs which user and which query — so the support response is not “MySQL is slow”, it is “user xyz ran this query 400 times in 10 minutes”.

It works alongside LVE, not as a replacement. PHP-side throttling stops the application; Governor stops the database side. Both are needed on a real shared host.

How to verify

Check that Governor is installed and active:

dbgovernor-stats
service db_governor status
cat /etc/container/mysql-governor.xml | head -20

To see who is currently using the most database resources:

dbtop -m
dbgovernor-stats --period=1h --user=top10

For a postmortem on a past incident:

dbgovernor-stats --period=24h --by=cpu
dbgovernor-stats --period=24h --user=<username> --queries

The --queries flag dumps the actual slow queries that hit limits. This is what you send to the customer when explaining throttling.

The fix

  1. Install Governor through CloudLinux’s installer: /usr/share/cloudlinux/governor/install_db_governor.sh. It modifies MySQL/MariaDB configuration to use the modified mysql binary that integrates with the LVE accounting.
  2. Set sane default limits in /etc/container/mysql-governor.xml. Reasonable starting points: 30% CPU, 10 MB/s read+write, 5 concurrent connections per user. Tune up for accounts that need it.
  3. Enable per-account override through the cPanel package settings, so packaging tiers map to DB limits the same way they map to LVE limits.
  4. When a tenant hits limits repeatedly, the next move is the slow query log — not raising the limit. mysqldumpslow and the EXPLAIN plan usually find a missing index in minutes.

The biggest behavioral change: a customer with a slow query no longer slows every other customer. They throttle themselves, and the support evidence is generated automatically. Stack Harbor turns on Governor as part of cPanel/WHM management.