BLU Discuss list archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss] to swap or not swap
- Subject: [Discuss] to swap or not swap
- From: blu at nedharvey.com (Edward Ned Harvey (blu))
- Date: Fri, 5 Sep 2014 13:22:24 +0000
- In-reply-to: <1409747695.27353.2.camel@micphys04.nci.nih.gov>
- References: <1409747695.27353.2.camel@micphys04.nci.nih.gov>
Did you want to have a discussion about swapping? Everyone would agree, you should always avoid swapping unless the memory requirement of some job exceeds the maximum ram you can put into your system, or unless it's a one-off job, or you simply don't care if it takes 100 or 1000 times longer than necessary, and nothing else in the system matters. I've certainly seen machines start swapping some active processes, and they become totally unresponsive. Ssh got swapped out, and can't get enough CPU share to respond to a login request before the client times out. You were lucky that you already had a logged-in terminal sitting there, and you can still "ls" because that was super hot in the cache and hasn't been expunged yet, but if you type "top" or "ps" or something that was already ejected from cache, then your prompt simply hangs indefinitely, as long as the runaway process is still active in swap memory. Some people would suggest disabling swap entirely, but I don't believe that's best. When you allow your system to have a small amount of swap (say 1G) then the kernel is able to swap idle processes and dead/zombie processes, making more room for cache & buffers & other stuff, which improves performance. By keeping the swap small, you limit the length of time that you get crushed, in the event a process accidentally runs away and gobbles memory incessantly. With 512M or 1G of swap, usually a runaway process will cause your system to utterly suck for a couple of minutes before the runaway process dies and things return to normal. This latter argument doesn't carry a lot of value. If you login to some long-running existing system you have, and check "top" or "free" you'll see some amount of swap space consumed, usually non-zero, but usually pretty small anyway. Say 10M or maybe 100M. So the real truth is, there's not much memory to gain by swapping out the dead/idle processes. "Yay, I've effectively increased my 16GB system to 16GB & 10MB." But I still recommend adding a small amount of swap to systems.
- Follow-Ups:
- [Discuss] to swap or not swap
- From: adler at stephenadler.com (Stephen Adler)
- [Discuss] to swap or not swap
- References:
- [Discuss] to swap or not swap
- From: adler at stephenadler.com (Stephen Adler)
- [Discuss] to swap or not swap
- Prev by Date: [Discuss] DNS providers
- Next by Date: [Discuss] to swap or not swap
- Previous by thread: [Discuss] to swap or not swap
- Next by thread: [Discuss] to swap or not swap
- Index(es):