Monday, December 20, 2010

MySQL Swapping to Disk - Swappiness to the rescue

I came across this blog post about MySQL swapping to disk. If you have issues with MySQL server swapping to disk, even with a large cache this blog post is for you.

The Problem:
MySQL server swapping large chunks of data into swap and then using reclaimed memory to cache more data.

The Solution:
Swappiness!

Swappiness defines how much a system can swap, the higher the number the more swapping happens, the number can be between 0 and 100. 0 is no swapping (we don't want that) and 100 is swap whenever possible thereby keeping memory clear.

# check current swappiness
/sbin/sysctl -a | grep swappiness

# set swappiness to something low, not 0
vm.swappiness = 1

# apply the settings right now
/sbin/sysctl -p

More Info:
http://www.incutio.com/blog/2009/11/27/mysql-swapping-resolution/

0 comments:

Post a Comment