Live data from Hacker News

Linux Performance: Why You Should Almost Always Add Swap Space

haydenjames.io

111–120 of 120 posts

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#111
post #52

Earlier quoted context omitted.

You 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/understand... - https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.linuxquestions.org/questions/linux-kernel-70/why... - https://kerneltalks.com/disk-management/swap-addition-in-lin... - https://linuxaria…

The 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…

>you do not get a free pass just because you messed with important stuff on a duct-tape-and-glue basis

Hahah. That made me laugh.

Before you go insulting people, maybe listen to what highly-experienced folks, like myself, have done.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#112

Earlier quoted context omitted.

It's a circular argument that people get into because they have the incorrect kernel settings. Even if you have 4TB of ram, someone will say to add more memory on disk. It just means the system is not configured correctly. I have 30k servers and not a single one of them has swap.

>I have 30k servers and not a single one of them has swap. Physical? VM? Cloud? I've never seen an environment with more than a couple carefully-tuned machines that didn't run swap on every last one

30k physical servers. 512GB to 1TB ram each.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#113
I've often disabled swap on systems running high-throughput databases like ElasticSearch and Cassandra because paging to disk will cause one or several nodes to slow down, which affects the performance of the whole cluster. The better thing to do in those cases is let the node fail right away by disabling swapping.

I fact, elasticsearch prefers to be run with `swapoff` : https://www.elastic.co/guide/en/elasticsearch/reference/curr...

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#114

Earlier quoted context omitted.

>I have 30k servers and not a single one of them has swap. Physical? VM? Cloud? I've never seen an environment with more than a couple carefully-tuned machines that didn't run swap on every last one

30k physical servers. 512GB to 1TB ram each.

>30k physical servers. 512GB to 1TB ram each.

You running an AWS data center?

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#115

I've often disabled swap on systems running high-throughput databases like ElasticSearch and Cassandra because paging to disk will cause one or several nodes to slow down, which affects the performance of the whole cluster. The better thing to do in those cases is let the node fail right away by disabling swapping. I fact, elasticsearch prefers to be run with `swapoff` : https://www.elastic.co/guide/en/elasticsearch/…

There's even a name for a slow node stalling an entire cluster: https://danluu.com/limplock.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#116
post #96

If you must use swap (you probably don't need to), then at least set zswap.enabled=1 in the kernel boot options, typically in grub. This will enable lzo compression of swap in memory so there is less writing to disk. Some newer kernels use lz4. Either way, what most folks are actually missing is the correct kernel settings for the amount of memory they have. Sadly, the kernel does not dynamically adjust these based o…

Those 3 sync's in rapid succession are secret-monkey-code for "tell the tape unit to rewind..", just FYI .. you don't strictly need 3. ;)

hehe it was also the secret monkey code on some old raid controllers to tell them to commit their cache to disk. It isn't even strictly required these days, but old bugs and features find their way into systems all the time, so I just keep the old incantations around as paranoid habits. :)

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#117

Earlier quoted context omitted.

30k physical servers. 512GB to 1TB ram each.

>30k physical servers. 512GB to 1TB ram each. You running an AWS data center?

Not a public cloud. It does involve some private cloud visualization and containers.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#118
post #96

Earlier quoted context omitted.

Those 3 sync's in rapid succession are secret-monkey-code for "tell the tape unit to rewind..", just FYI .. you don't strictly need 3. ;)

hehe it was also the secret monkey code on some old raid controllers to tell them to commit their cache to disk. It isn't even strictly required these days, but old bugs and features find their way into systems all the time, so I just keep the old incantations around as paranoid habits. :)

Yeah, in my case its pure muscle-memory from the 80's. Can't stop myself from doing it the moment I start typing "sync"...

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#119

Earlier quoted context omitted.

I set vm.swappiness to 0 on my Fedora laptop. Meaning the kernel will only swap to save the system. I've been doing this for years and had no issues. Edit: Actually in recent kernels, which I am using, 0 means it's disabled. I was thinking of 1.

It does not help, just makes the problem appear later in a more dire way. Try overcommit settings instead.

I googled that and was pleasantly surprised to learn something new.[1]

But if I'm reading that right I would probably want to do both. Because overcommit settings seem to be a memory saving technique. To avoid needing swap by decreasing the allowed overcommit memory.

Anyways, in the many years that I've been changing vm.swappiness I've never had any issues and I've always had a minimum of 8G RAM so I don't think this will be a big issue.

1. http://engineering.pivotal.io/post/virtual_memory_settings_i...

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#120
post #105
post #74

Earlier quoted context omitted.

Nope, I'm not off the mark. But nice try at deflecting your lack of understanding.

Please don't be uncivil on Hacker News, regardless of how much someone knows about swap. https://news.ycombinator.com/newsguidelines.html

That should have gone to the person to whom I replied
Post reply on HN