Resource management (cgroups or nice)

Hi all,

Lately I am researching on options to apply proper resource management for users and services on Virtualmin + CentOS setup (the same applies on Ubuntu too). What I mean by resource management is to be able to limit and prioritize the services and users in such a system. For example not allowing heavy usage of one service to block other, or for one user/website to block all the others.

There are few things that can be done now with Virtualmin + CentOS:

  1. Lower the priority of the backups by setting nice and ionice values fot the scheduled jobs in the Webmin advanced settings

  2. Create priority for pam_limits by creating /etc/security/limits.d/80-priority.conf and put something like that:

* soft priority 3 postfix soft priority 4 apache soft priority 1 mysql soft priority 1 root soft priority 0
  1. We can edit the wrapper scripts to set up individual nice values for the php-cgi processes by putting
exec nice -n 3 /usr/bin/php-cgi

Setting up nice will also set-up ionice (i/o is usually bigger bottleneck than cpu)

Another general option is to use cgroups which is available in CentOS 6. It is generally recommended to use cgroups as being more advanced and having more options. Though the setup of cgroups will be more complex. Probably the long term way to go is cgroups.


  1. Did anybody tried to apply any resource management?
  2. Did you tried to apply cgroups?
  3. Shall we work together in order to find a proper resource management for Virtualmin. Right now it is a drawback from cPanel + CloudLinux which offer relatively good resource management


you will want to silence any standard output from the cronjob btw (will be nosiy without doing so)

i built a small bash script application to do this. its called “PrioSrv”. Ill be loading it onto a publicly available repository (along with all my other free software and scripts) in coming time;

it has two parts. on debian or ubuntu, they go under /usr/local/sbin/priosrv and /usr/local/etc/priosrv.conf

the general idea is that you tell PrioSrv to run every hour using cron, and it changes the CPU priority of the specific services. using the configuratioin file, you can seperate services into groups (like webserver, mail server, dns server, etc), and you can specify all other processes to use a specific priority without belonging to a group.

finally, any processes which do Not properly return a PID # (when running the application “pidof”), can have their CPU priority changed by using directly its PID file

anyways, these files have been attached. it’s been tested on Debian/Ubuntu linux flavor systesm. it uses Bash, and it relies on the “renice” and “pidof” commands to complete its job.