[conspire] Vee don't need no steenkin' swap! ;-)

Michael Paoli Michael.Paoli at cal.berkeley.edu
Tue Dec 18 01:54:22 PST 2018


> Date: Mon, 17 Dec 2018 14:00:59 -0800
> From: Rick Moen <rick at linuxmafia.com>
> To: conspire at linuxmafia.com
> Subject: Re: [conspire] successful install, at last

> Good news:  The Red Hat people say there should be no problem.
> https://www.redhat.com/en/blog/do-we-really-need-swap-modern-systems

Oh, it's been said/implied by lots more than the Red Hat folks, and for
quite a long time now.  "It depends" - at least somewhat, but, e.g.:
Ever run a "live" distro from optical ISO?  You're generally running
without swap ... and no hard drive / SSD at all?  Yes, definitely without
swap.  Likewise if same is booted from flash (e.g. USB flash), then
typically one is also running without swap (though it may be possible to
configure/use swap on flash or that or other rw media).

There's lots more well written information out there, but in general,
if there's ample RAM, swap is not required - though it can sometimes also
be advantageous to have (at least some) swap - even in such circumstances.

There are also some circumstances where it's highly advantageous to have
exactly no swap at all.  E.g., a host with more than ample RAM for the
application (including operating system, etc.), high performance / heavy
usage - most notably heavy use of RAM (e.g. large in-RAM database or
similar).  In such cases, any swap activity would be such a major
performance hit, one may prefer to crash/bork/replace the host,
rather that make any use of swap at all - this is more commonly the case
when there are many such hosts working together, and dropping and
adding hosts quickly and in automated fashion is not only easy, but
already set up to do so.

"Of course" there are also advantages to having swap, e.g. want to be
able to crash and dump to swap to analyze, e.g. kernel failure/panic?
That's not really an option if there's no swap (notwithstanding other
ways to dump/capture that data).
Want the system to (semi-)gracefully degrade in performance, rather than
get wedged or outright fail, when system is under much memory pressure?
Does depend somewhat upon the typical application loads, but in many cases
swap will allow a system otherwise under significant memory pressure to
continue to operate fairly well, whereas without swap it may not be able
to do that.  Example would be where some/many of the applications aren't
so actively in use, but need to remain loaded (processes running - even
if mostly idle) ... those can be swapped in and out ... there'd be more
latency for them to first respond when swapped back in, but otherwise not
all that much impact to performance, etc. - especially if there isn't also
significant disk contention for swap vs. other drive I/O.
And semi-random mention - one of my favorites ... tmpfs.  There are many
advantages to tmpfs - notably can be much more efficient and reduced
drive I/O.  But if the storage demands of your tmpfs exceed RAM, well, if
you've got available swap, tmpfs will use that, as needed, beyond its
primarily using RAM (and if you have no swap, then tmpfs is limited to
RAM only).  Swap might also be used for "suspend to disk(/drive)" or
"hibernate" (though can also configure that to be written elsewhere).

But in the more general cases, typically one wants some adequate amount
of swap - and drive storage is relatively inexpensive, so typically one
will set up some fair bit of swap space (e.g. 1 to 4x physical RAM).

And slight technical bit - Linux mostly does paging, rather than swapping.
But for (mostly historical) reasons, the storage is still referred to as
swap.  Swap generally involves entire memory of process going between
RAM and drive, whereas with paging, inactive / less active pages of RAM
are involved, and needn't be the entire memory image of the process.





More information about the conspire mailing list