MySQL and swapping

by nivas on November 24, 2014

Did you ever encounter swap space issue with MySQL ? This problem is really annoying and here are some possible solutions :

1) Track memory usage.. Try to identify the bottleneck using query below. It is not trivial job to zero in on the problem heap.. There are several temp tables being created at run time. Also estimating the OS cache being used by system MYISAM tables is not easy

SELECT ( @@key_buffer_size + @@query_cache_size + @@innodb_buffer_pool_size + @@innodb_additional_mem_pool_size + @@innodb_log_buffer_size + 80 * ( @@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size + @@join_buffer_size + @@binlog_cache_size + @@thread_stack + @@tmp_table_size ) ) / (1024 * 1024 * 1024) AS MAX_MEMORY_GB;

2) Configure the swappiness to 10 or 15.. By default it might be set at 60

cat /proc/sys/vm/swappiness will give the current swappiness value on your system

3) Set Numa interleaving to ON. Read below links to understand the correlation between NUMA architecture and swapping

http://blog.jcole.us/2010/09/28/mysql-swap-insanity-and-the-numa-architecture/

http://www.percona.com/doc/percona-server/5.5/performance/innodb_numa_support.html

Comments on this entry are closed.

Previous post:

Next post: