ubuntu cgroup howto

Hi

Need to limit php-cgi procs?
Here some nice howto:

aptitude install cgroup-bin
service cgconfig stop

here the content of my /etc/cgconfig.conf

#mounts the cgroupfilesystems
mount {
   cpu = /sys/fs/cgroup/cpu;
   cpuset = /sys/fs/cgroup/cpuset;
   memory = /sys/fs/cgroup/memory;
}

#defines a group trasuser which is pinned to cpu 3 of the quadcore system
group trashuser {
   cpuset {
      cpuset.mems = 0;
      cpuset.cpus = 3;
   }
}

#defines the group defaultphp where all php-cgi processes get 75% of the quadcore cpu and 3GB Ram
group defaultphp {
   cpu {
      cpu.shares = 750;
   }
   memory {
      memory.limit_in_bytes = 3G;
   }
}

here the content of my cgrules.conf

#the unix user webuser01 gets pinned in group trashuser
webuser01        cpuset        trashuser/
#pinnes all php-cgi procs to group defaultphp
*:php-cgi    cpu,memory    defaultphp/
#pinnes all other procs to the default profile
*        *        default/
service cgconfig start

Here a nice link with resources

Hint:
If “service cgconfig restart” not works try to unmount all mounted cgroupfilesystems. You will find them under “cat /proc/mounts”
After that it should start.

Have Fun!