Hi,
I have configured 4 GB swap on my server, but it is never used. When I check at /proc/meminfo it always show as 0 used.
Am I missing some thing here? Please help.
Printable View
Hi,
I have configured 4 GB swap on my server, but it is never used. When I check at /proc/meminfo it always show as 0 used.
Am I missing some thing here? Please help.
As long as you have plenty of RAM, everything should go directly into it. Linux doesn't go into swap unless it's out of RAM.
Swap will be used when your RAM is all consumed. If you never reach your RAM limits your swap remains untouched, No worries its very normal. Maybe when you grow traffic swap will be used and will be highly helpful.
The problem is I have checked my other servers and all of them are using SWAP space and those have enough memory too. The customer is complaining his server is slow. I just wondered that, is this anything to do with slowness?
There's plenty else to slow the server down. Is mySQL and PHP cached? is the site making a massive amount of HD access? As far as performances go, swap slow down things, it would be a problem if you're using a massive amount of swap. Your memory management is as optimized as possible if everything's in RAM.
There are three simple checks related to swap:
- make sure your swap partition is mounted (swapon -s under linux)
- make sure your swap is non-zero size - see SwapTotal and SwapFree parameters in /proc/meminfo
- check /proc/sys/vm/swappiness - it should be > 0
As for server speed - website speed depends on lots of factors, from numbers of concurrent connections and memory size to SQL query speed.
I recomend to do some profiling for your top web pages.
Actually Linux will go into swap before all RAM is fully consumed. Usually after your RAM usage is >30ish % (determined by swapiness parameter), Linux may decide to swap out unfrequently used pages in favour for file cache to improve the general performance of the system. If your swappiness value is too low, then the swapping does not occur as frequently.
Thank you guys. I am monitoring this server and swap is never used. I checked the value at /proc/sys/vm/swappiness and it shows 50. What is it mean? How can I change the value? Please help.
thank you
koppan
swappiness = 0 gives you the behaviour of trying not to swap unless necessary, such as being out of physical memory (RAM)
swappiness = 100 tells the kernel swap whenever the kernel feels like it
swappiness = 50 gives you the in-between behaviour.
In short, the higher the swappiness, the more it will swap.
ex. to set swapiness to 100:
Code:echo 100 > /proc/sys/vm/swappiness
This is default value. Kernel will swap out rarely used pages so free memory can be effectively used for disk caching (boost performance a lot) or by active processes.Quote:
Originally Posted by koppan
Too big value (70 and more) can slow down a server because of lots of IO request to/from swap.
Zero value will force kernel to keep rarely used pages in memory and make it dirty.