Intro
Since upgrading my server to Ubuntu 14.04 I’m having issues with memory swap to disk all the time while at least 50% of the RAM is used for cache. After digging through many incorrect and risky comments on the interwebs and a few good pages (here and here) I found the settings below to be working really good.
Howto (tl;dr)
Note: I’m not responsible when this turns into something bad for you. Before applying them to your system, always research configurations until they make sense to you. Never simply copy/paste and hope for the best!
1. First add these lines to /etc/sysctl.conf
# swap when less than N % mem is available
vm.swappiness = 10
# cache inodes (50 = don't shrink inode cache)
vm.vfs_cache_pressure = 50
# % memory available for all processes -- some suggest 50
vm.overcommit_ratio = 100
# 0 = fuzzy available memory guessing : bad
# 1 = high performance, high risk : bad
# 2 = don't use more memory than swap + overcommit_ratio % : good
vm.overcommit_memory = 2
2. Then tell the running system to apply them:
sudo sysctl -p
And you’re good to go.
Leave a Reply