Swappiness Tuning
Strategies for Tuning Swappiness¶
1. Check Current Value¶
2. Temporary Adjustment¶
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:
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
0to 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.