I started out with FreeBSD. I love FreeBSD, and all the BSDs, however in the workplace, Linux is much more common as a server platform. No, I am not including Mac OS X as a BSD. I do not hold Apple in a very high regard, that is just my opinion, you must draw your own conclusions. Please use the dry erase markers on the white board. That way it’s easier to change your mind in the future,
Back to my point.
Several years ago, when the 2.4 kernel was all the rage. I noticed that Linux did not behave like FreeBSD in regards to swapping to the disk. FreeBSD would swap when available RAM was in short supply. Linux however, seemed to swap to disk, just for the sake of swapping. It always seemed silly to me, and definitely a hit to performance.
Even with the 2.6 kernel, and all it’s wonder, default swap settings are fairly liberal in my opinion. The good news is, vm.swappiness can be adjusted via the proc filesystem.
Echoing values into /proc/sys/vm/swappiness works, but we are no longer savages hurling values into proc files in the wilderness . Modern Linux types are refined, disciplined. We use sysctl, and /etc/sysctl.conf, (so as to retain settings when we reboot).
If you have gigs upon gigs of ram, why would you want to swap data to the disk? Remember good people,
it’s all about I/O.
Here’s how to do it.
First, check your current settings.
debian:~# sysctl vm.swappiness
vm.swappiness = 60
The scale is from 0 to 100,
0 being the least swappy,
and 100 being the swappiest.
I am showing you how to adjust the settings,
I am not making any recommendations as to
what those settings should be.
Me, I don’t want swap anymore than I absolutely have to swap.
I’m going to set my vm.swappiness to a lower value, 10.
debian:~# sysctl -w vm.swappiness=10
vm.swappiness = 10
The new value will not persist during a reboot.
If you want it to persist,
add this line to your /etc/sysctl.conf
vm.swappiness = 10
Here's some more information regarding vm.swappiness.
Linux: VM Swappiness Autoregulation
swapping and the value of /proc/sys/vm/swappiness
Linux performance tuning - /proc/sys/vm/swappiness
Adrian Thiele