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

From: Claus Herwig <lists_at_checon.de>
Date: Thu 01 Mar 2012 - 00:16:02 GMT
Message-ID: <4F4EBFC2.6010509@checon.de>

>
>> does anyont know how to limit the cpu and memory of the vps?
>
> http://wiki.linux-vserver.org/util-vserver:Cgroups

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 2.6.36.4-vs2.3.0.36.39-beng and
util-vserver 0.30.216-pre3000, both from repo.psand.net, 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

Done.

Greets,
  Claus

-- 
CHECON   EDV-Consulting und Redaktion
         Claus Herwig * Barer Straße 70 * 80799 München
         +49 89 27826981 * Fax 27826982 * c.herwig@checon.de
Received on Thu Mar 1 00:16:12 2012
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 01 Mar 2012 - 00:16:19 GMT by hypermail 2.1.8