[lxc-users] Profile settings to limit RAM and SWAP

Ron Kelley rkelleyrtp at gmail.com
Tue Jun 27 12:20:53 UTC 2017


Sorry - I have been trying a few things to get this working.  In my email below, I mistakenly said "512MB of RAM and 512MB of swap per container” but the example was using 512M RAM and 1G swap.

Still, the same issue exists.  How to properly limit the container to X-RAM and Y-SWAP (and have “free -m” and “top” show properly).




> On Jun 27, 2017, at 8:15 AM, Ron Kelley <rkelleyrtp at gmail.com> wrote:
> 
> Greetings all,
> 
> Running LXD 2.14 on Ubuntu 16.04 and need to find a way to properly set limits for RAM and SWAP for my containers.
> 
> The goal: profile 512MB of RAM and 512MB of swap per container (total 1G)
> 
> 
> My current profile:
> --------------------
> config:  limits.cpu: "2"
>  limits.memory: 512MB
>  limits.memory.swap.priority: “1"
>  raw.lxc: lxc.cgroup.memory.memsw.limit_in_bytes = 1512M
> --------------------
> 
> 
> 
> However, according to “top” and “free -m”, the available memory = (RAM - ProcessesUsed) and does not include swap.  Example:
> --------------------
> top - 12:08:40 up 1 min,  0 users,  load average: 0.59, 1.12, 2.23
> Tasks:  19 total,   2 running,  17 sleeping,   0 stopped,   0 zombie
> %Cpu(s): 11.8 us,  4.4 sy,  0.0 ni, 82.3 id,  0.2 wa,  0.0 hi,  1.4 si,  0.0 st
> KiB Mem :   524288 total,   263776 free,    75492 used,   185020 buff/cache
> KiB Swap:  1024000 total,  1019936 free,     4064 used.   263776 avail Mem
> --------------------
> 
> In the above output, I would expect to see about 1263776 avail Mem (Swap free + RAM free).  
> 
> What am I missing?
> 
> -Ron



More information about the lxc-users mailing list