Linux OS Internals (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is Swappiness (`vm.swappiness`) and how does it balance RAM vs Disk?
senior Levellinux-osAdvanced Internals
In Simple Words: Controls the kernel's aggressiveness in moving anonymous memory pages to swap space vs reclaiming file system cache (0 to 100, default 60):
vm.swappiness = 0: Kernel will only swap to prevent Out-Of-Memory conditions.vm.swappiness = 100: Aggressively swaps anonymous memory to disk to maximize file system cache.- Production Databases (PostgreSQL / Redis / Kubernetes): Set to
1or10to prevent swapping active database memory to slow disk, which causes sudden latency spikes.