QA
Intermediate LevelLinux Commands & SysAdmin

What is Linux Swap Space and how does vm.swappiness (0-100) control kernel memory swapping?

❓ Interview Prompt: Explain Linux Swap space, vm.swappiness sysctl parameter, page cache eviction vs memory swapping, and setting optimal swappiness.

Swap Space acts as virtual memory overflow on disk when physical RAM is exhausted:

'vm.swappiness' Parameter (0-100):

Controls the kernel's aggressiveness in swapping anonymous application RAM out to disk vs evicting filesystem page cache:

•
Swappiness = 60 (Default): Balanced swapping.
•
Swappiness = 10 (Recommended for Database & K8s nodes): Keeps application RAM in physical memory, swapping only under extreme RAM pressure.

Code Implementation Example

bash
# Check current swappiness setting
cat /proc/sys/vm/swappiness

# Temporarily set swappiness to 10
sudo sysctl vm.swappiness=10

# Persist setting in /etc/sysctl.conf
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
💡Tuning kernel swappiness settings for database servers.
🎯 Interview Key Takeaway

Set vm.swappiness=10 on database and Kubernetes servers to prevent premature memory swapping to disk.

#Swap#swappiness#Memory#sysctl#Intermediate
Back to all Linux Commands & SysAdmin Questions→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?