1

this is graph of my server ram enter image description here

you can see in graph that every time I restart mysqld, swap becomes zero. But increases over time.
If i put innodb buffer pool in large size swap rises faster and if I lower it swap rising is slower.

enter image description here

2 Answers 2

7

You don't mention any performance problems, just that it is using swap.

This is completely normal.

If there are things in RAM that are being used very infrequently, the kernel will swap them out to make more room for caches that are being used frequently.

This can be adjusted with the vm.swappiness kernel parameter, but generally it works well the way it is, and adjusting it to not use swap will often make performance worse, not better. A good explaination on exactly what that adjust can be found in this question: https://unix.stackexchange.com/questions/32333/what-does-the-vm-swappiness-parameter-really-control

How much swapping is ok and how much signals a problem is dependent on a lot of factors - you can really only tell by looking at performance metrics for awhile after adjusting the swappiness. It will depend on the speed of the underlying disks, how often background processes wake up, how much disk IO is saved by using that RAM for caching vs keeping things in RAM. All of that depends on your hardware and workload.

4
  • can you take a look at "swap in /out" graph too? is it normal Aug 11, 2014 at 21:13
  • @mehdiazizi Looks fine to me
    – Grant
    Aug 11, 2014 at 21:20
  • So how much of swapping is bad? Aug 11, 2014 at 23:42
  • @mehdiazizi answer updated.
    – Grant
    Aug 11, 2014 at 23:46
0

Completely agree with Grant,Swap utilization is not always a performance issue but if Database is swapping you will see a performance issue but it all depend on the situation.Next time when your system is swapping can you please run this script to find out which process is swapping

       http://northernmost.org/blog/find-out-what-is-using-your-swap/

Again like Grant suggest vm.swappiness parameter for Database like Oracle,RedHat suggest it to reduce it to as low 10(by default set to 60) and mostly used by algorithm

       swap_tendency=mapped_ratio/2 + distress + vm_swappiness


    if swap_tendency < 100 kernel will reclaim a page from page cache
    if swap_tendency >=100 Page will be eligible for swap 

Also there are some mysql tuner script but please test it in test env before applying in production http://mysqltuner.com/

Also now MySQL support hugepages which are not swappable and you will see performance improvement as the size of TLB reduce and your cache hit will increase http://dev.mysql.com/doc/refman/5.0/en/large-page-support.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .