Since sysadmin are looking to have racing beast servers, they are confonted to the problem of performance optimization.
Nowadays it is not uncommon to see a server with 32G or 96G of RAM or even more.
Why to mount so much in memory?
Well it is the use that imposes it:
- Video editing
- HD compression
- Heavy applicative consumption like clustering or high availability architectures
In this blog we will speek about swapiness which is a kernel module that defines when linux has to start to write in the SWAP (an allocated space in the disk) to relieve the RAM.
It may seem obvious that with access times in milliseconds for Hard Disk and in nanoseconds for RAM, it is better to write in the RAM.
vm.swappiness = 0 : Swapping will be activated urgently only to avoid out of memory condition.
vm.swappiness = 60 : This is the default value and means that from 40% of Ram occupancy, the kernel writes to the swap.
vm.swappiness = 10 : This what is recommended to improve performance.
vm.swappiness = 100 : The kernel will swap aggressively.
To see your swappiness setting :
cat /proc/sys/vm/swappiness 60
Let’s consider that we have a server having 32G of RAM. fixing the swappiness to 5 is enough since kernel will use swap only when the free RAM space is less or equal to 1.6G.
As root set the swappiness value:
echo 5 > /proc/sys/vm/swappiness
or alternatively, run:
sysctl -w vm.swappiness=5
Verify your changes:
cat /proc/sys/vm/swappiness 5
sysctl vm.swappiness vm.swappiness = 5
To change this value permanently edit /etc/sysctl.conf and modify (or add if not exist):
vm.swappiness = 5
sysctl -p swappoff -a && swapon -a
I hope that this blog helped you. Please visit our website for other interesting blogs and feel free to leave your feedbacks and thoughts. Till next time!
Latest posts by ZIADI Mohamed Ali (see all)
- How to show mounted devices in Linux? - July 25, 2017
- How to use Positional parameters and special variables in Linux - June 28, 2017
- Linux: Connect to your WiFi network through CLI? - June 25, 2017
- How to find a file in Linux? - March 19, 2017
- Mysql: How to find table and database size? - January 9, 2017