Enforce policy to hard/soft LXC 2.0.9


(Riddhi Patel) #1

Hi,

I am working with LXC 2.0.9.

I want to know, can we apply memory enforcement policy ( to hard/soft) as mentioned at LXD_2_0_ResourceControl for LXD in section “Memory”

Is there any lxc configuration parameter available for this ?


(Stéphane Graber) #2

That’s the memory cgroup with keys like lxc.cgroup.memory.XYZ


(Riddhi Patel) #3

I have allocated 3 GB (out of 4GB ) of Memory to my container via “lxc.cgroup.memory.limit_in_bytes = 3072M”.

Still I am seeing that my container, (when required ) start eating up more than 3 GB of memory.
In my container. “/proc/meminfo” shows correct 3 GB.
From host, “/sys/fs/cgroups/memory/lxc/Container/memory.limit_in_bytes” shows 3 GB.
From host side , “lxc-info” reports 3 GB used memory, when is in loaded condition.

But “top” command from host, shows memory keep on reducing, when Container required more than 3 GB.

So, how can I strictly limit it to 3 GB only ?


(Stéphane Graber) #4

Note that the memory cgroup by default does not consider SWAP, if you have swap on your machine, you’ll want to pass the kernel boot parameter to turn on swap accounting and then use memory.memsw.limit_in_bytes for your limits.

What does memory.usage_in_bytes or memory.memsw.usage_in_bytes show for your container?


(Riddhi Patel) #5

Yupp.

That solve the problem and limit the memory.