Home WebsiteCloudLinux MySQL Governor: Stop One Account from Hogging the Database

CloudLinux MySQL Governor: Stop One Account from Hogging the Database

by Knowledge Base Linux
CloudLinux MySQL Governor throttles the one account hogging the shared database server

LVE limits keep CPU, RAM and disk I/O fair between accounts — but they do not see inside the database server. One customer with an unindexed WooCommerce database can monopolize MySQL or MariaDB for everyone, while their LVE graphs look almost idle. CloudLinux MySQL Governor closes that blind spot: it watches database usage per hosting account and throttles the abusers automatically. This guide explains how Governor works, its operating modes, and the dbtop and dbctl tools you will use day to day. It assumes CloudLinux is already installed — if not, start with our CloudLinux installation guide.

How CloudLinux MySQL Governor Works

MySQL Governor is a set of tools that monitor every query a shared server’s database executes and attributes the cost — CPU time and disk read/write throughput — to the hosting account that owns the database user. When an account’s usage stays above the limits you define, Governor restricts that account: its queries are deprioritized and held to much lower restricted limits for a period, so everyone else’s queries flow normally again. When the account’s average usage falls back in line, the restriction lifts automatically.

Two requirements are worth knowing before you install it:

  • Governor works with the CloudLinux builds of MySQL and MariaDB (the cl-MySQL / cl-MariaDB packages). The installation swaps a stock server for the CloudLinux build of the same version family — plan a maintenance window, as the database restarts during the switch.
  • It complements, not replaces, LVE limits: LVE governs the PHP processes that send queries; Governor governs the database work those queries cause.
Monitoring per-user database load with CloudLinux MySQL Governor and dbtop

Installing MySQL Governor – CloudLinux MySQL Governor

Install the package and run the Governor installer, which detects your current MySQL/MariaDB version and installs the matching CloudLinux build:

yum install governor-mysql
/usr/share/lve/dbgovernor/mysqlgovernor.py --install

Follow the installer’s prompts carefully — it will tell you which version it is about to install and when the database will restart. When it finishes, the db_governor service monitors all database users. Verify it is running and start your rollout in monitor mode (below) rather than throttling anyone on day one.

Governor Modes: off, monitor, single and all – CloudLinux MySQL Governor

Governor’s behavior is controlled by its mode, set in the dbgovernor.xml configuration and visible in CloudLinux Manager → MySQL Governor:

  • off — Governor does nothing. Useful only for troubleshooting.
  • monitor — Governor collects per-user CPU and I/O statistics but never restricts anyone. This is the correct mode for the first week: it shows you who your heavy database users actually are.
  • single — When a user exceeds a limit, only the exceeded parameter is restricted (for example, runaway reads get the restricted read limit while CPU stays untouched). The balanced default for most hosts.
  • all — When a user exceeds any limit, all restricted values (CPU, read and write) are applied at once. Stricter; reserve it for servers with chronic abuse.

Governor judges usage over several averaging windows, so a single heavy query does not trigger a restriction — sustained abuse does. Restricted users are held at the restricted limits for a cooldown period, and repeat offenders stay restricted longer. Limits are expressed as CPU percentage plus read and write throughput per user, with separate, much lower values that apply while restricted.

Watching the Database Live with dbtop

The fastest way to answer “who is hammering MySQL right now?” is dbtop — a top-style, real-time view of database usage per user:

dbtop

It shows each database user’s current CPU and read/write usage against their limits, updating live. When the server feels slow and the process list is a wall of MariaDB threads, one minute in dbtop tells you exactly which account to look at. The same statistics, with history, are in CloudLinux Manager → MySQL Governor in WHM or DirectAdmin — use the history view to prove a pattern to a customer instead of arguing about a single spike.

Managing Restricted Users with dbctl

The dbctl command-line tool manages Governor users. The operations you will use most:

dbctl list               # all users and their Governor limits
dbctl list-restricted    # users currently being throttled
dbctl unrestrict <username>   # lift a restriction manually
dbctl restrict <username>     # restrict a user manually

Typical workflow: a customer complains their site is slow, dbctl list-restricted shows their account is throttled, and dbtop plus the Governor history show why — usually a plugin update gone wrong, a backup plugin dumping tables at noon, or search bots hammering an uncached search page. Fix the cause first, then dbctl unrestrict to restore full speed immediately instead of waiting out the cooldown.

A Sane Rollout Plan for Production Servers

  1. Install and monitor for a week. Run in monitor mode and review the statistics daily. Identify your top database users and what “normal” looks like on your hardware.
  2. Set limits from data, not defaults alone. Place the normal limits comfortably above your typical busy accounts, and the restricted limits low enough to protect the server but high enough that a restricted site still loads.
  3. Switch to single mode. Let Governor throttle only the parameter being abused. Watch support tickets and the restricted list for false positives.
  4. Treat restrictions as a diagnostic, not a punishment. Every restricted account has a story — a missing index, a runaway cron, a bot flood. The long-term fix is the customer’s queries; Governor just buys everyone else breathing room while you find it.

Troubleshooting Common Governor Problems

No statistics are being collected. Check the db_governor service is running and that the server actually runs a CloudLinux MySQL/MariaDB build — Governor cannot monitor a stock or third-party database server.

A user is restricted again every day. Do not just keep unrestricting them. Enable the slow query log for their databases and look for full table scans and missing indexes; chronic daily restriction is a code problem wearing a resource costume.

After a MariaDB/MySQL upgrade, Governor stops working. Major database upgrades can replace the CloudLinux build. Re-run the Governor installer so the correct monitored build is in place, and confirm statistics resume.

Restricted user’s site is unusable. Your restricted limits are probably too low for a legitimate-but-heavy workload (large WooCommerce stores are the usual case). Raise that account’s individual limits in CloudLinux Manager once you have verified the load is real customer traffic, not abuse.

Conclusion

CloudLinux MySQL Governor gives you the missing half of shared-hosting fairness: per-account visibility and automatic throttling inside MySQL and MariaDB. Roll it out in monitor mode, set limits from your own data, prefer single mode, and manage incidents with dbtop and dbctl. Do that, and one account’s bad queries stop being the whole server’s outage.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.