Why my container is swapping?


Active Member
Oct 15, 2008
I have a container which has very slow performance, and trying to debug this i realised that it's swapping so much even if it has a lot of RAM memory available:

Screenshot 2019-06-12 at 15.09.06.png
These are the status graphs of the hypervisor:

Screenshot 2019-06-12 at 15.09.44.png
Screenshot 2019-06-12 at 15.09.37.png
Screenshot 2019-06-12 at 15.09.30.png
Screenshot 2019-06-12 at 15.09.24.png

As you can see the host does not seems to be overloaded.

Another strange thing is that the container is seeing 64 Gb of swap instead of 8:

Screenshot 2019-06-12 at 15.12.42.png

Swappiness on the host node is 0:

root@node3 ~ # cat /proc/sys/vm/swappiness

Could you help me please?
No. You'll need to implement the workaround discussed in the links I provided.

Just to be sure: are you referring to the following workaround?

ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 2 -maxdepth 2 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \;
ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 3 -maxdepth 3 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \;
ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 4 -maxdepth 4 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \;
ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 5 -maxdepth 5 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \;
ExecStartPost=/bin/find /sys/fs/cgroup -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \;

Is it correct that I should apply this on the host node for Proxmox itself and containers and on VMs?

Well, that may work for you. In my case, I implemented the following on all nodes:

cat /etc/sysctl.d/local.conf

cat /etc/tmpfiles.d/mem-swap.conf
#Type Path                                              Mode UID  GID  Age Argument
w   /sys/fs/cgroup/memory/system.slice/memory.swappiness -    -    -    -   0

After rebooting each node in sequence, it resolved the problem for me. YMMV.

EDIT: systemd-tmpfiles requires a ".conf" extension or the file is ignored.
Last edited:


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!