3 ms·
Cargo cult system administration. No, you should not 'almost always add swap space'. What you should do instead is tune your system for its intended use. If y
by jacquesm 9y ago
Cargo cult system administration.
No, you should not 'almost always add swap space'. What you should do instead is tune your system for its intended use.
If you need swap as an 'early warning system' that you're about to run out of memory you're already doing it wrong and the OOM killer is a piece of code that has default settings that can be tuned, ditto for the virtual memory manager in the kernel.
http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html http://www.oracle.com/technetwork/articles/servers-storage-d...
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-memory-captun https://access.redhat.com/documentation/en-us/red_hat_enterp...
Select appropriate equivalent for your kernel where applicable, and don't forget about the per-process limits in ulimit.
This sort of 'almost useless' advice is pretty annoying, it shows that the writer has an interest in the matter but didn't bother to dig in deep enough to make the advice truly useful.
Also, the comment on that article that implies that swap will allow you to update a running process because it is backing the image is wrong, the backing is simply done through the filesystem and swap space has nothing to do with it. The practical upshot of which is that you're not going to be able to reclaim the space held by the binary if you should remove it because the 'file is busy' until the last instance of that process exits. In the meantime, if you really want to run the newer version under the old name or path then you're free to unlink it or 'mv' it to a different location and to start the new binary from the default location. On some Unixes you can even overwrite the binary using an mv command making it look like the old one has disappeared but again, under the hood it will still be held open, you can check this using lsof or whatever is your local equivalent to see that the file is indeed still present. In a pinch (and you really really have messed up if you ever need this trick) you can re-link the running image by hard linking to the inode.
- warrenm 9y agoYou should just about always add at least some swap. Anyone who thinks otherwise hasn't read much or seen very many systems. start here: - https://www.kernel.org/doc/gorman/html/understand/understand013.html https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.kernel.org/doc/gorman/html/understand/understand014.html https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.linuxquestions.org/questions/linux-kernel-70/why-is-my-linux-server-using-swap-when-inactive-memory-is-available-4175580818 https://www.linuxquestions.org/questions/linux-kernel-70/why... - https://kerneltalks.com/disk-management/swap-addition-in-linux https://kerneltalks.com/disk-management/swap-addition-in-lin... - https://linuxaria.com/howto/linux-memory-management https://linuxaria.com/howto/linux-memory-management - https://kernelnewbies.org/Linux_4.8#head-a0b674ff33af7e3e7b80fcfa266a9d366f094e93 https://kernelnewbies.org/Linux_4.8#head-a0b674ff33af7e3e7b8... - https://kernelnewbies.org/Linux_4.11#head-680ed3eee137456d6a0665b3191be34d9a17bab2 https://kernelnewbies.org/Linux_4.11#head-680ed3eee137456d6a... - https://kernelnewbies.org/Linux_4.14#head-5327850512ba28763de4c8838246b4145df59033 https://kernelnewbies.org/Linux_4.14#head-5327850512ba28763d... - https://help.ubuntu.com/community/SwapFaq#How_much_swap_do_I_need.3F https://help.ubuntu.com/community/SwapFaq#How_much_swap_do_I... - https://access.redhat.com/solutions/15244 https://access.redhat.com/solutions/15244 - https://serverfault.com/a/684800/2321 https://serverfault.com/a/684800/2321 - https://serverfault.com/q/329928/2321 https://serverfault.com/q/329928/2321 - https://serverfault.com/q/25653/2321 https://serverfault.com/q/25653/2321 - https://serverfault.com/a/825915/2321 https://serverfault.com/a/825915/2321 - https://askubuntu.com/q/184217/3544 https://askubuntu.com/q/184217/3544 - https://antipaucity.com/2011/08/08/why-technical-intricacies-matter/#.WjfiqlQ-fgo https://antipaucity.com/2011/08/08/why-technical-intricacies... I've been in environments ranging from a few dozen individual servers to 100s of 1000s. In companies ranging from mom-and-pop shops to international investment banks. Every last one is configured with swap. Because unless you have done all the profiling to truly know you don't need it, you should be running it.
- jacquesm 9y agoThe majority of your links seem to be chosen simply because they have the word 'swap' on it somewhere, not because they make the case why having 'some swap' is a must. I wrote a kernel from scratch, besides that I did quite a bit of transaction oriented stuff and built the server side of a very successful messaging platform. That does not make me an expert either but I do have some minimal understanding of what goes on under the hood. If you are simply configuring swap space on a better-safe-than-sorry basis then I would rather not have you near a system whose response has to be deterministic because it almost certainly will fail in some unpredictable way sooner rather than later. Yes it is difficult stuff, no you do not get a free pass just because you messed with important stuff on a duct-tape-and-glue basis. See, swap is just a stay of execution, once a system starts swapping it is as good as out of control anyway so in the vast majority of cases that I am familiar with you want that situation to announce itself loud and clear and in a way that gives you back control. You then do postmortem and you fix it so it will not happen again. That is far preferably over having systems that remain partially broken but pretend to be fine. I know plenty of people run after each other claiming great insight by quoting the various help-yourself sites but it amounts to absolutely nothing when you suddenly find yourself trying to figure out why your transaction queues are overflowing because some system in the pipe suddenly decided 100ms is as good as 10 as long as things keep flowing. If on the other hand your systems are not important enough to properly set them up with static resources committed to long running processes and with strict limits on what logged in users can do from the command line then this advise is going to fall on deaf ears because you did not need reliability in the first place. Note that in many business context latency is far more important than throughput.
- cat199 9y agoif swap is 'cargo cult administration', pretending it won't save you a few times even with all the safeguards you claim that you perfectly do is 'narcissist administration'. if your systems are so advanced that you've done all of this up front profiling, you'd know why the system in the pipe decided 100ms is as good as 10 because you'd be monitoring and alerting on memory/swap and would get the message when it hits 80%-90%, and be logging in while leaky process is blowing up into your swap space. no need for a 'postmortem' if you can have a surgery..