1

I can set cpulimit, iolimit, etc for mysql process by moving its pid into cgroup.procs file of a cgroup.

But single mysql process handles all the queries(threads) and I cant set cpulimit to the entire mysql process. I want to set cpulimit only for a mysql/mariadb user.

When I see the database processlist, I get the thread_IDs (TIDs) of the mysql users' queries being executed. enter image description here

I can see those TIDs consuming alot of cpu usage through htop command. enter image description here

How do I set cpulimit, iolimit for a mysql/mariadb user so that the combined queries of that user does not exceed a certain cpu usage limit?

2
  • Additional DB information request, please. OS, Version? Any SSD or NVME devices on MySQL Host server? Post TEXT data on justpaste.it and share the links. From your SSH login root, Text results of: A) SELECT COUNT(*) FROM information_schema.tables; B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; E) STATUS; not SHOW STATUS, just STATUS; G) SHOW ENGINE INNODB STATUS; for server workload tuning analysis to provide suggestions. Dec 30, 2023 at 1:27
  • Post TEXT data on justpaste.it and share the links. Additional very helpful OS information includes - please, htop 1st page, if available, TERMINATE, top -b -n 1 for most active apps, top -b -n 1 -H for details on your mysql threads memory and cpu usage, ulimit -a for list of limits, iostat -xm 5 3 for IOPS by device & core/cpu count, df -h for Used - Free space by device, df -i for inode info by device, free -h for Used - Free Mem: and Swap:, cat /proc/meminfo includes VMallocUused, for server workload tuning analysis to provide suggestions. Dec 30, 2023 at 1:28

1 Answer 1

1

As there's a pool of MariaDB threads, there's no fixed allocation to a user that could be used a cgroup limit.

Internal resource limits on users can apply and achieve CPU based limits in some crude and approximate ways.

If users are all on different databases then using containers or multi-instance (templated) systemd services on a per user basis (each user gets a dedicated DB) could apply the strict (and richly featured) cgroup based controls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.