kswapd0 eating cpu on control plane when running out of RAM #799
-
Hi all, I have a question. In a simple dev setup (I tear it down daily, no need for HA etc), I have a single CX21 control plane node (2cpu, 4GB RAM) with several agent nodes. While playing around with a tool which launches a shipload of jobs, I got to the point that the k3s-server process is at 80% of the available memory on the control plane node. Next, the node becomes unresponsive (the k8s api is unresponsive, more exactly). Ssh-ing into the machine, I observe that k3s-server is hitting the limits (that's ok, I know what I did and that I need a bigger machine if I want to continue doing this), but also that kswapd0 is at 80%-100% of cpu usage. About a few thousand linux fora teach me that this happens what kswapd0 starts looking for swap space when there isn't any. Indeed, on our microos setup, swapping is turned off. (Running commands like Is there anything that could/should be done to avoid kswapd0 from making things worse? Is there any setting which tells kswapd0 to never even look for swap space to begin with? Just to repeat: I know that this is probably never an issue if I use a bigger control-plane machine, but I'm raising this here as someone else might also run into this for other more legitimate reasons, and perhaps one of the more linux-savvy people here actually knows what to do with this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@valkenburg-prevue-ch FYI (From GPT-4): kswapd0 is a kernel process that is responsible for freeing up memory pages when the system is running out of physical memory. When your k3s-server process is consuming a lot of memory, kswapd0 tries to find pages that can be moved into swap space to free up physical memory. If there's no swap space configured, kswapd0 can be stuck in a loop trying to free up memory, causing high CPU usage. The fact that setting swappiness to 0 or trying to disable swapping (with In a situation where there is no swap space, and memory is being heavily used, the kernel can start killing processes to free up memory, guided by the Out-Of-Memory (OOM) killer. This could explain why your k3s-server process becomes unresponsive. There's no setting to tell kswapd0 to not look for swap space because that's fundamentally what it's designed to do. Instead, there are a few options to address your problem:
Remember that not having enough memory for your workloads can lead to unpredictable behavior and can make your system unstable. It's always a good idea to monitor your memory usage and ensure you have enough resources for your workloads. |
Beta Was this translation helpful? Give feedback.
@valkenburg-prevue-ch FYI (From GPT-4):
kswapd0 is a kernel process that is responsible for freeing up memory pages when the system is running out of physical memory. When your k3s-server process is consuming a lot of memory, kswapd0 tries to find pages that can be moved into swap space to free up physical memory. If there's no swap space configured, kswapd0 can be stuck in a loop trying to free up memory, causing high CPU usage.
The fact that setting swappiness to 0 or trying to disable swapping (with
swapoff -a
) doesn't impact your situation is expected. These commands would only be effective if you had swap space configured. The swappiness parameter controls the tendency of the kernel …