[lxc-users] LXD 2.14 - Ubuntu 16.04 - kernel 4.4.0-57-generic - SWAP continuing to grow

Fajar A. Nugraha list at fajar.net
Sat Jul 15 07:30:54 UTC 2017


On Sat, Jul 15, 2017 at 1:58 AM, Ron Kelley <rkelleyrtp at gmail.com> wrote:

> Wondering if anyone else has similar issues.
>
> We have 5x LXD 2.12 servers running (U16.04 - kernel 4.4.0-57-generic - 8G
> RAM, 19G SWAP).  Each server is running about 50 LXD containers - Wordpress
> w/Nginx and PHP7.  The servers have been running for about 15 days now, and
> swap space continues to grow.  In addition, the kswapd0 process starts
> consuming CPU until we flush the system cache via "/bin/echo 3 >
> /proc/sys/vm/drop_caches” command.
>
> Our LXD profile looks like this:
> -------------------------
> config:
>   limits.cpu: "2"
>   limits.memory: 512MB
>   limits.memory.swap: "true"
>   limits.memory.swap.priority: "1"
> -------------------------
>
>
> We also have added these to /etc/sysctl.conf
> -------------------------
> vm.swappiness=10
> vm.vfs_cache_pressure=50
> -------------------------
>
> A quick “top” output shows plenty of available Memory and buff/cache.


On the host?

What does top/htop show on the container?


> But, for some reason, the system continues to swap out the app.  For
> example, our “server-4” machine shows 8G total RAM, 500MB free, 2.5G
> available, and 5G of buff/cache.  Yet, swap is at 5.5GB and has been slowly
> growing over the past few days.  It seems something is preventing the apps
> from using the RAM.
>
>
Even if the host has ample RAM, containers won't be able to use it if their
usage is over the limit. Hence why I asked for htop in the container.


>
> To be honest, we have been battling lots of memory/swap issues using LXD.
> We started with no tuning, but the app stack quickly ran out of memory.
> After editing the profile to allow 512MB RAM per container (and restarting
> the container), the kswapd0 issue happens.  Given all the issues we have
> had with memory and swap using LXD, we are seriously considering moving
> back to the traditional VM approach until LXC/LXD is better “baked”.
>
>
>

In the end use whatever works for you.

I've had enough problems with swap in the past (non-lxc setup) that
nowadays I simply disable swap altogether, and configure my apps (e.g. set
max connection, max concurrent process, etc) to be able to live with what
they have.

-- 
Fajar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170715/a31dcf85/attachment.html>


More information about the lxc-users mailing list