Sunday, October 18, 2009

They write it to the file system cache which is managed by Linux kernel virtual memory manager. Since I've high performance RAID controller I need to decrease the number of flushes.

How do I tune virtual memory subsystem under Linux operating systems for better performance?
Linux allows you to tune the VM subsystem. However, tuning the memory subsystem is a challenging task. Wrong settings can affect the overall performance of your system.

I suggest you modify one setting at a time and monitor your system for sometime. If performance increased keep the settings else revert back.

Say Hello To /proc/sys/vm

The files in this directory can be used to tune the operation of the virtual memory (VM) subsystem of the Linux kernel:

pdflush

Type the following command to see current wake up time of pdflush:

# sysctl vm.dirty_background_ratio

Sample outputs:

sysctl vm.dirty_background_ratio = 10

vm.dirty_background_ratio contains 10, which is a percentage of total system memory, the number of pages at which the pdflush background writeback daemon will start writing out dirty data. However, for fast RAID based disk system this may cause large flushes of dirty memory pages. If you increase this value from 10 to 20 (a large value) will result into less frequent flushes:

# sysctl -w vm.dirty_background_ratio=20

swappiness
Type the following command to see current default value:

# sysctl vm.swappiness

Sample outputs:

vm.swappiness = 60

The value 60 defines how aggressively memory pages are swapped to disk. If you do not want swapping, than lower this value. However, if your system process sleeps for a long time you may benefit with an aggressive swapping behavior by increasing this value. For example, you can change swappiness behavior by increasing or decreasing the value:

# sysctl -w vm.swappiness=100

dirty_ratio

Type the following command:

# sysctl vm.dirty_ratio

Sample outputs:

vm.dirty_ratio = 40

The value 40 is a percentage of total system memory, the number of pages at which a process which is generating disk writes will itself start writing out dirty data.

This is nothing but the ratio at which dirty pages created by application disk writes will be flushed out to disk.

A value of 40 mean that data will be written into system memory until the file system cache has a size of 40% of the server's RAM. So if you've 12GB ram, data will be written into system memory until the file system cache has a size of 4.8G.