I have 3x Proxmox VE nodes in a cluster, and the issue I'm about describe has been problematic for me for years now. I've been trying to find the "proper" solution to this problem, but alas, I find more criticism for the method I use than real solutions.
A few years ago I learned about the performance impact of content being in swap (this is the same effect/cost between Windows and Linux systems). Firstly, as more content is in swap, that increases the disk usage for a function that in-effect is meant to extend RAM. If this happens across many hosts and VMs then the disk impact is compounding. Secondly, this also increases CPU usage to manage all the swap pages (the cost naturally increases as more swap is used).
As such, I set up my monitoring to alert me when any of my monitored systems hit 10% swap usage or higher. And now several of my systems regularly alert me every few days. Clearly there is a pattern and repeat cause here. When I check out each of these systems, they aren't even close to using all their RAM, often 50% RAM used by applications or lower. But in every single case, the Linux kernel has used up all the available RAM for cache.
Initially, I just flushed swap with "sudo swapoff -a && sudo swapon -a && htop" so that the swap flushed back into RAM and htop so I can see the task is done. But as I continued to work through this aspect, I observed that swap was refilling very frequently, and that dropping the caches bought me several days worth of time before it refilled. So I have been also manually issuing "sync; echo 3 > /proc/sys/vm/drop_caches". After doing additional recent research into this topic, I am now switching that to "sync; echo 1 > /proc/sys/vm/drop_caches".
Up until this point, I have been doing this manually, while I try to identify not only the actual proper thing I should be doing, but the cause. I believe I have identified the cause, but I am still leaning towards a practice (dropping caches) that is widely criticised as "cargo cult systems administration", as in, a reckless "solution" without actually understanding the cause or problem properly.
Yesterday I took a deeper look at my monitoring history, and I think I have identified the primary "cause" of the cache usage spikes, but why the cache doesn't flush itself does not make sense to me.
Now, I aspire to be as good a sys admin as I possibly can, always looking to improve. Naturally, I have a daily task which does a full VM disk image backup of each of the VMs I care about in my cluster. The task starts at 1am, every day, and varies from one node to the next, but usually takes about 3 hours to complete.
Now, what did I notice when I looked at my monitoring patterns yesterday? The cache jumps happen when the backup tasks happen. And the caches _never_ clear themselves. Each backup task each day increases the Linux kernel cache on each node, and after a few days starts just using swap. Let me reiterate, there is PLENTY of unused RAM on each of the nodes, I keep them at 50% usage or less. I do not have ballooning enabled on any VM either. I'm running about 30 VMs, and only one is Windows, one is Debian, one is pfSense and the rest is Ubuntu. Additionally, all nodes in the cluster are fully updated as of a few days ago, and again, this effect has been happening over the years, so this is not localised to a specific version so far as I can tell.
So, at this point, I'm thinking of just setting up a daily cron job on each node at say 5am to run "sync; echo 1 > /proc/sys/vm/drop_caches", but I'm really thinking there must be a better way to do this.
What can you folks tell me here? I'm really not finding any actual other solutions anywhere on the internet.
A few years ago I learned about the performance impact of content being in swap (this is the same effect/cost between Windows and Linux systems). Firstly, as more content is in swap, that increases the disk usage for a function that in-effect is meant to extend RAM. If this happens across many hosts and VMs then the disk impact is compounding. Secondly, this also increases CPU usage to manage all the swap pages (the cost naturally increases as more swap is used).
As such, I set up my monitoring to alert me when any of my monitored systems hit 10% swap usage or higher. And now several of my systems regularly alert me every few days. Clearly there is a pattern and repeat cause here. When I check out each of these systems, they aren't even close to using all their RAM, often 50% RAM used by applications or lower. But in every single case, the Linux kernel has used up all the available RAM for cache.
Initially, I just flushed swap with "sudo swapoff -a && sudo swapon -a && htop" so that the swap flushed back into RAM and htop so I can see the task is done. But as I continued to work through this aspect, I observed that swap was refilling very frequently, and that dropping the caches bought me several days worth of time before it refilled. So I have been also manually issuing "sync; echo 3 > /proc/sys/vm/drop_caches". After doing additional recent research into this topic, I am now switching that to "sync; echo 1 > /proc/sys/vm/drop_caches".
Up until this point, I have been doing this manually, while I try to identify not only the actual proper thing I should be doing, but the cause. I believe I have identified the cause, but I am still leaning towards a practice (dropping caches) that is widely criticised as "cargo cult systems administration", as in, a reckless "solution" without actually understanding the cause or problem properly.
Yesterday I took a deeper look at my monitoring history, and I think I have identified the primary "cause" of the cache usage spikes, but why the cache doesn't flush itself does not make sense to me.
Now, I aspire to be as good a sys admin as I possibly can, always looking to improve. Naturally, I have a daily task which does a full VM disk image backup of each of the VMs I care about in my cluster. The task starts at 1am, every day, and varies from one node to the next, but usually takes about 3 hours to complete.
Now, what did I notice when I looked at my monitoring patterns yesterday? The cache jumps happen when the backup tasks happen. And the caches _never_ clear themselves. Each backup task each day increases the Linux kernel cache on each node, and after a few days starts just using swap. Let me reiterate, there is PLENTY of unused RAM on each of the nodes, I keep them at 50% usage or less. I do not have ballooning enabled on any VM either. I'm running about 30 VMs, and only one is Windows, one is Debian, one is pfSense and the rest is Ubuntu. Additionally, all nodes in the cluster are fully updated as of a few days ago, and again, this effect has been happening over the years, so this is not localised to a specific version so far as I can tell.
So, at this point, I'm thinking of just setting up a daily cron job on each node at say 5am to run "sync; echo 1 > /proc/sys/vm/drop_caches", but I'm really thinking there must be a better way to do this.
What can you folks tell me here? I'm really not finding any actual other solutions anywhere on the internet.