Wednesday, March 30, 2022

Disable Swap In MySQL

 Disable Swap In MySQL


Swapping occurs when your systems runs out of physical memory and starts using the special disk known as swap.

When your RAM is occupied it starts swapping and your disk I/O gets utilized which slows down the server and if proper steps are not taken then system can crash. 

The default is usually 60

 you can check this by running:

sysctl vm.swappiness

To avoid swappiness, execute the following command on your command line.

 sysctl -w vm.swappiness=0 

The default swapiness value is 60 which will be changed to 0 which indicates that it is disabled now

For MariaDB databases, it is recommended to set swappiness to a value of 1.

vm.swappiness = 1

While some disable swap altogether, and you certainly want to avoid any database processes from using it

 It can be prudent to leave some swap space to at least allow the kernel to fall over gracefully should a spike occur.

 Having emergency swap available at least allows you some scope to kill any runaway processes.


No comments: