Container uses more SWAP than allocated

r0g

Well-Known Member
May 31, 2016
32
0
46
28
Hi!

I have noticed that one of my containers uses much more SWAP memory than allocated. Allocated are 512MB and it uses well over 700MB, although there is still plenty of RAM free. Can anyone give me a hint why?

upload_2019-1-10_15-49-38.png

upload_2019-1-10_15-45-2.png

free -m says:
upload_2019-1-10_15-46-19.png

Any ideas?
 
You can set the swappiness to a lower value. On the Proxmox host run:

Code:
sysctl vm.swappiness=1

this should make the CT use swap when there's high memory consumption only.

The reason why this happens is because of how swapping is implemented in cgroups version 1 (LXC doesn't support v2 yet).
 
Thanks for reply. I set
Code:
sysctl vm.swappiness=1
and did
Code:
swapoff -a
waited about 15 minutes and did
Code:
swapon -a

Now the SWAP of this container is back to 0% and the container uses 34% of its RAM.
On this container runs a vesta with nginx. If I now call a website that runs there, the SWAP goes directly and slowly up again. In addition, if I start another VM on the node, the SWAP directly rises to over 100% from the already mentioned container.

Why does that happen?
 
Now the SWAP of this container is back to 0% and the container uses 34% of its RAM.
On this container runs a vesta with nginx. If I now call a website that runs there, the SWAP goes directly and slowly up again.

This looks like normal behavior to me. LXC Containers use the swap from the host, and the only way to completely avoid swapping is to disable swapping on the host.

The swap rising over 100% is because of how swapping in cgroups implemented. "memory" is actually RAM + swap in cgroups version 1. When you add a swap to your container to use, it adds extra swap space on top of the current memory + swap.

Take a look at the following documentation in the sections related to swapping (2.4 and so on):
https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt


In addition, if I start another VM on the node, the SWAP directly rises to over 100% from the already mentioned container.

What is running on this VM? Is it connected in any way to the container?
 
okay, thank you for clearing this up.

What is running on this VM? Is it connected in any way to the container?

No its not... There is a windows 10 running and the vm is normally turned off. I booted it to test it. After setting vm.swappiness to 1 this seems not to be the case anymore.
 

About

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 yours easily in our online shop.

Buy now!