Linux swap not used, even when OS run out of memory

The swap is at low usage, and the OS sometime run out of memory and start scarifying processes

swapon -s 

Filename                                Type            Size    Used   Priority
/dev/vda1                               partition       2047992 75030       1

Memory is around 97% used. any idea what is wrong ? I tried turning swap off/on, that did not help.v

Centos 6.5 / kernel 2.6.32

cat /proc/meminfo

MemTotal:       15000800 kB
MemFree:          300532 kB
Buffers:           11364 kB
Cached:           211224 kB
SwapCached:            0 kB
Active:         12613992 kB
Inactive:        1854012 kB
Active(anon):   12555272 kB
Inactive(anon):  1690320 kB
Active(file):      58720 kB
Inactive(file):   163692 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2047992 kB
SwapFree:        2047992 kB
Dirty:                68 kB
Writeback:             0 kB
AnonPages:      14245460 kB
Mapped:            19440 kB
Shmem:               176 kB
Slab:              76136 kB
SReclaimable:      48572 kB
SUnreclaim:        27564 kB
KernelStack:        2400 kB
PageTables:        35352 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     9548392 kB
Committed_AS:    7996680 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       40680 kB
VmallocChunk:   34359684884 kB
HardwareCorrupted:     0 kB
AnonHugePages:   9834496 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        9204 kB
DirectMap2M:    15417344 kB

swappiness looks ok

cat /proc/sys/vm/swappiness
60

Solution 1:

Very interesting you have almost 300 MB free and 200 cached probably your swappines it's not aggressive , I played many times in my past with this in order to have more performance with hosted VPS , so you have to change your vm.swappiness kernel parameters to set a fine threshold for you these links are good for you but take care test it before go in production.

https://askubuntu.com/questions/103915/how-do-i-configure-swappiness https://en.wikipedia.org/wiki/Swappiness

I hope it helps!

Solution 2:

Another option to try messing with in /proc or your /etc/sysctl.conf is /sys/vm/overcommit_ratio. By default Linux starts killing processes before the swap is more than slightly utilized.

The exact formula used can be found by running the command "man proc"