I'm administering a Debian Linux x86_64 server with 125GB RAM, a 10GB swap partition and a swappiness value of 60.
A free -gw
output prints:
total used free shared buffers cache available
Mem: 125 20 1 25 0 103 78
Swap: 9 1 7
Every night, a cron job runs which is very disk R/W intensive and raises used memory by 2GB during its execution before returning to ~20GB.
In the same time frame, certain long-running containerized Python processes (especially gunicorn) are paged out.
With time, those processes will gradually fill the swap - after a couple of weeks, it will be 99% full.
I can clear the swap by either restarting the processes or disabling and re-enabling with swapoff
and swapon
. But the swap usage of the Python processes will just creep up slowly again.
I guess that part of the explanation may be, that because of the nightly cron job the Kernel is prioritizing the filesystem cache higher than the Python processes. But I also guess that some software bug in the memory handling of those Python processes may be to blame.
A friend has suggested that I purchase even more RAM so there will be more room for the filesystem cache. That seems excessive to me. I would like to more precisely diagnose the cause of the swapping and find some software solution to the problem.
So now I pass the question to Serverfault - what do you think of this phenomenon, and where should I go from here?