The first reason: one combined limit
Historically, swap was discouraged in Kubernetes for two reasons. [1]
Under cgroup v1, the controls treated memory and swap as a single combined limit rather than letting operators set an independent limit for disk swap. [2]
Without independent tracking, a process could page large amounts of anonymous memory out to disk, which made a container's real memory usage unpredictable and hard to isolate. [3]
The second reason: slow disks
The second reason was the latency penalty of paging to slow spinning disks, which fast NVMe Local SSDs largely eliminate. [4]
What the post says this makes practical
Together, these make it practical to increase pod density and buffer against memory spikes without sacrificing cluster stability. [5]
By enabling the Linux kernel to page out anonymous memory to disk, node swap acts as a shock absorber during traffic spikes or periods of heavy memory oversubscription. [6]
Sources
- The Kubernetes project source says: Historically, swap was discouraged in Kubernetes for two reasons. Scaling Kubernetes Workloads with Node Swap
- The Kubernetes project source says: Under cgroup v1, the controls treated memory and swap as a single combined limit rather than letting operators set an independent limit for disk swap. Scaling Kubernetes Workloads with Node Swap
- The Kubernetes project source says: Without independent tracking, a process could page large amounts of anonymous memory out to disk, which made a container's real memory usage unpredictable and hard to isolate. Scaling Kubernetes Workloads with Node Swap
- The Kubernetes project source says: The second reason was the latency penalty of paging to slow spinning disks, which fast NVMe Local SSDs largely eliminate. Scaling Kubernetes Workloads with Node Swap
- The Kubernetes project source says: Together, these make it practical to increase pod density and buffer against memory spikes without sacrificing cluster stability. Scaling Kubernetes Workloads with Node Swap
- The Kubernetes project source says: By enabling the Linux kernel to page out anonymous memory to disk, node swap acts as a shock absorber during traffic spikes or periods of heavy memory oversubscription. Scaling Kubernetes Workloads with Node Swap