<div dir="ltr">If you remove the memory limit of container is the result the same?<div><br></div><div>operation system tends not to use too much memory one time instead of trigger out-of-memory killing later.</div><div><br></div><div>Removing memory limit of container is a bit like over-commit and probably encourage operation system to consume more RAM (and less swap).</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-06 17:56 GMT+08:00 Ron Kelley <span dir="ltr"><<a href="mailto:rkelleyrtp@gmail.com" target="_blank">rkelleyrtp@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I don’t have a way to track the memory usage of a container yet, but this issue seems very consistent among the containers.  In fact, all containers have a higher than expected swap usage.<div><br></div><div><br></div><div>As a quick test, I modified the container profile to see if removing the swap and memory limits would help (removed the “lxc.cgroup.memory.memsw.<wbr>limit_in_bytes” setting and changed "limits.memory.swap=false” ).  The odd thing now is the available memory to the container seems to be maxed out at the limits.memory setting and does not include swap:</div><div><br></div><div>Top output from container</div><div>-----------------------------</div><div><div>top - 09:48:50 up 9 min,  0 users,  load average: 0.62, 0.67, 0.72</div><div>Tasks:  20 total,   1 running,  19 sleeping,   0 stopped,   0 zombie</div><div>%Cpu(s):  2.7 us,  3.8 sy,  0.0 ni, 93.2 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st</div><div>KiB Mem :   332800 total,    52252 free,    99324 used,   181224 buff/cache</div><div>KiB Swap: 19737596 total, 19737596 free,        0 used.    52252 avail Mem</div></div><div>-----------------------------</div><div><br></div><div>Notice the "52252 avail Mem”.  Seems the container is maxed out at 325MB despite having access to 19G swap.</div><div><br></div><div>Confusing…</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div><div><div class="h5"><div>On Jun 6, 2017, at 5:40 AM, Fajar A. Nugraha <<a href="mailto:list@fajar.net" target="_blank">list@fajar.net</a>> wrote:</div><br class="m_-6228955532810778794Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr" style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 6, 2017 at 4:29 PM, Ron Kelley<span class="m_-6228955532810778794Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:rkelleyrtp@gmail.com" target="_blank">rkelleyrtp@gmail.com</a>></span><span class="m_-6228955532810778794Apple-converted-space"> </span><wbr>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">(Similar to a redit post:<span class="m_-6228955532810778794Apple-converted-space"> </span><a href="https://www.reddit.com/r/LXD/comments/53l7on/how_does_lxd_manage_swap_space" rel="noreferrer" target="_blank">https://www.reddit.com/<wbr>r/LXD/comments/53l7on/how_<wbr>does_lxd_manage_swap_space</a>).<br><br>Ubuntu 16.04, LXC 2.13 running about 50 containers.  System has 8G RAM and 20G swap.  From what I can tell, the containers are using lots of swap despite having free memory.<br><br><br>Top output from the host:<br>------------------------------<wbr>-<br>top - 05:23:24 up 15 days,  4:25,  2 users,  load average: 0.29, 0.45, 0.62<br>Tasks: 971 total,   1 running, 970 sleeping,   0 stopped,   0 zombie<br>%Cpu(s):  8.9 us,  8.1 sy,  0.0 ni, 81.0 id,  0.7 wa,  0.0 hi,  1.2 si,  0.0 st<br>KiB Mem :  8175076 total,   284892 free,  2199792 used,  5690392 buff/cache<br>KiB Swap: 19737596 total, 15739612 free,  3997984 used.  3599856 avail Mem<br>------------------------------<wbr>-<br><br><br>Top output from a container:<br>------------------------------<wbr>-<br>top - 09:19:47 up 10 min,  0 users,  load average: 0.52, 0.61, 0.70<br>Tasks:  17 total,   1 running,  16 sleeping,   0 stopped,   0 zombie<br>%Cpu(s):  0.3 us,  2.2 sy,  0.0 ni, 96.5 id,  0.0 wa,  0.0 hi,  1.0 si,  0.0 st<br>KiB Mem :   332800 total,   148212 free,    79524 used,   105064 buff/cache<br>KiB Swap:   998400 total,   867472 free,   130928 used.   148212 avail Mem<br>------------------------------<wbr>-<br><br></blockquote><div><br></div><div><br></div><div>Do you have history of memory usage inside the container? It's actually normal for linux to keep some elements in cache (e.g. inode entries), while forcing out program memory to swap. I'm guessing that's what happened during "busy" times, but now you see the non-busy times. Linux won't automatically put entries in swap back to memory if it's not used.</div><div><br></div><div>In the past I had to set vm.vfs_cache_pressure = 1000 to make linux release inode cache from memory. This was especially important on servers with lots of files. Nowadays I simply don't use swap anymore.</div><div><br></div><div>-- </div><div>Fajar</div></div></div></div></div></div><span class=""><span style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">______________________________<wbr>_________________</span><br style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">lxc-users mailing list</span><br style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:lxc-users@lists.linuxcontainers.org" style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">lxc-users@lists.<wbr>linuxcontainers.org</a><br style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://lists.linuxcontainers.org/listinfo/lxc-users" style="font-family:Consolas;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">http://lists.linuxcontainers.<wbr>org/listinfo/lxc-users</a></span></div></div><br></div></div><br>______________________________<wbr>_________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.<wbr>linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" rel="noreferrer" target="_blank">http://lists.linuxcontainers.<wbr>org/listinfo/lxc-users</a><br></blockquote></div><br></div>