Re: Re: [vserver] how to limit the cpu and memory of the vps?

From: songjun435 <>
Date: Thu 01 Mar 2012 - 01:48:50 GMT
Message-ID: <>

Thank you!
my kernel is,It does not support cgroup.
Seemingly,the cgroup is supported after 2.6.26version.

I user yum to install libcgroup in my OS like this:
yum install libcgroup
but there is no avaliable package.

so can I use cgroup in the kernel?
If yes,what should I do?
Thank you very much!


From: Claus Herwig
Date: 2012-03-01 08:16
To: vserver
Subject: Re: [vserver] how to limit the cpu and memory of the vps?

>> does anyont know how to limit the cpu and memory of the vps?

as I learned just yesterday on IRC, that page isn't really uptodate
regarding memory...

Short version for memory cgroup:

Grab a not too old kernel with the necessary kernel config parameters
set, and a recent util-vserver.
For me (Debian squeeze) kernel and
util-vserver 0.30.216-pre3000, both from, did work out of
the box.

Type "mount" to verify that /dev/cgroup is mounted and has the necessary
mount options. You'll want rw,cpuset,cpu,cpuacct,memory at least. And
you don't want the ns option. (With mentioned versions the util-vserver
init script did all that on system startup.)

Make sure your vserver config tree has cgroup directories.
mkdir -p /etc/vservers/.defaults/cgroup
mkdir -p /etc/vservers/<vsname>/cgroup

See what memory limits you have on your running vserver:
cat /dev/cgroup/<vsname>/memory.limit_in_bytes
cat /dev/cgroup/<vsname>/memory.memsw.limit_in_bytes

memory.limit_in_bytes is the physical RSS hard limit (what the rss.hard
rlimit was in earlier days)
memory.memsw.limit_in_bytes is the limit for physical RAM + Swap
together (I think this was rss.soft in earlier days)

Set some sensible limits for the running vserver:
echo "2G" >/dev/cgroup/<vsname>/memory.limit_in_bytes
echo "3G" >/dev/cgroup/<vsname>/memory.memsw.limit_in_bytes

Make the limits permanent:
echo "2G" >/etc/vservers/<vsname>/memory.limit_in_bytes
echo "3G" >/etc/vservers/<vsname>/memory.memsw.limit_in_bytes

Treat your vserver to a realistic memory display:
echo "VIRT_MEM" >>/etc/vservers/<vsname>/flags



CHECON EDV-Consulting und Redaktion
         Claus Herwig * Barer Straße 70 * 80799 München
         +49 89 27826981 * Fax 27826982 *
Received on Thu Mar 1 01:49:08 2012

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 01 Mar 2012 - 01:49:08 GMT by hypermail 2.1.8