Skip to content

Swappiness Tuning

Strategies for Tuning Swappiness

1. Check Current Value

sysctl vm.swappiness

2. Temporary Adjustment

sudo sysctl vm.swappiness=10
This change is temporary and will not persist after reboot. Use it for testing before making permanent adjustments.

3. Permanent Adjustment

Edit /etc/sysctl.conf and add:

vm.swappiness=10
Then apply the change:
sudo sysctl --system

4. Consider Workload and RAM

  • High RAM systems: Lower swappiness (e.g., 10) to maximize RAM usage.
  • Low RAM systems: Increase swappiness (e.g., 60) to avoid OOM kills.
  • Real-time systems: Set to 0 to prioritize RAM retention.

5. Monitor and Test

Use tools like free, top, or vmstat to observe memory usage before and after adjustments. Avoid over-reliance on swap for sustained workloads, as it degrades performance.