Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Resource isolation

longdafeng edited this page Oct 13, 2014 · 13 revisions

cgroups (abbreviated from control groups) is a Linux kernel feature to limit, account, and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups. In Jstorm, we use cgroup to manage CPU resources. You need to check the following items and configuration before use.

  • Check current user's uid and gid in /etc/passwd file. For example if user is admin, then check admin's uid and gid in /etc/passwd file

  • cgroups feature is supported or not by current system's kernel

    Check /etc/cgconfig.conf exist or not. If not exists, please "yum install libcgroup". If exists, set CPU sub system's mount directory location, and change uid/gid to jstorm user's uid/gid in that config file, let's take 500 for example, pay attention to the uid/gid mentioned before.

  mount {    
      cpu = /cgroup/cpu;
  }
  

  group jstorm {
       perm {
               task {
                      uid = 500;
                      gid = 500;
               }
               admin {
                      uid = 500;
                      gid = 500;
               }
       }
       cpu {
       }
  }
  • Then start cgroup service
service cgconfig restart
chkconfig --level 23456 cgconfig on

Note: cgconfig.conf can only be changed in root mode.

Or execute command directly

This is a cgconfig.conf config file example. For example if JStorm's start up user is admin, and admin's uid/gid in current system is 500 (check /etc/passwd and you can see uid and gid), then relative CPU sub system's jstorm directory's uid/gid need to be set the same value. So that jstorm has relative privilege to create relative directory and do the relative settings in that directory for jstorm's process which need to isolate resources.

mkdir /cgroup/cpu
mount  -t cgroup -o cpu none /cgroup/cpu
mkdir /cgroup/cpu/jstorm
chown admin:admin /cgroup/cpu/jstorm

Enable Cgroups in JStorm

open cgroup in jstorm config file storm.yaml

   supervisor.enable.cgroup: true
Clone this wiki locally