CT keeps swapping despite having plenty of free RAM

Tony

Renowned Member
Nov 4, 2010
113
10
83
I have a CT that keeps swapping, despite having plenty free RAM.

Code:
 free -m
               total        used        free      shared  buff/cache   available
Mem:            3000         271        2194           0         534        2728
Swap:           1024           8        1015

I think the CT keeps swapping because atop (GitHub - Atoptool/atop: System and process monitor for Linux) reports a high value of pagescan and swout every few seconds.

Any suggestion what to do about this?

This CT is a ssh server with many users, and it has a bind mount to a very large ZFS dataset on the node. The primary purpose is to allow users to access that dataset via ssh/scp.
 
update: I'd like to reduce swapiness as recommended by some sources I could find, but it seems doing so requires a reboot of the CT, which I would like to avoid.
 
update: I'd like to reduce swapiness as recommended by some sources I could find, but it seems doing so requires a reboot of the CT, which I would like to avoid.
I'm not sure I understand your question correctly but sysctl vm.swappiness=0 (for example) affects the running kernel and all CTs share the kernel with the host. Therefore, you cannot change it for a single CT but you can change it for all CTs (and the host) without rebooting anything.
 
thanks for the hint. I read in this post that it seems possible to set swapiness for individual CTs but it's not confirmed by Proxmox yet.

In my case atop reports swap activities, but vmstat does not. I am not sure if it's something to worry about. The small amount of used swap (8M) is really tiny, but I keep wondering why swap is used when there is still 2GB free memory.
 
I am not sure if it's something to worry about. The small amount of used swap (8M) is really tiny, but I keep wondering why swap is used when there is still 2GB free memory.
I would not worry. Linux will swap out memory to make room for I/O buffers. If that memory is not actively used (and stays in swap instead of being read back into memory), then the end result is better use of available memory. Writing to swap is almost never a problem (even when the bar turns red). When the system is reading a lot from swap (trashing because of insufficient memory), then you have slowdowns and problems.
 
I have been keeping an eye on this container, and still could not figure out the cause of pagescan/swapout activities on this CT. I gave it 4G RAM and set swapiness=10 on the node, run `swapoff -a; swapon -a` on node.

Any hint how to find out which process causes pagescan/swapout activities? I have been using atop and vmstat, which shows me the amount of pagescan/swapout activities but not the cause of them.
 

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!