[buug] Using swap on an SSD...or not.

Nick Moffitt nick at zork.net
Thu Oct 1 03:04:11 PDT 2009


Rick Moen:
> Mem:   2074864k total,  1194224k used,   880640k free,   168352k buffers
> Swap:  1951888k total,       88k used,  1951800k free,   196864k cached
> 
> Point is, swap isn't actually within a country mile of being "used" in
> any real sense, despite that "88k" thing, which really amounts to the
> swapper thread tapping gently on the swap partition to ensure that
> it's still there.

On servers, in particular, you do your level best to keep the situation
this way, because once you get yourself reliant on swap for providing
regular service, your throughput just becomes unacceptable.  

Earlier someone mentioned disabling swap entirely, and that is a pretty
drastic move.  Often it's mentioned that those 88k up there are useful
for smooth operation so that the swapper thread doesn't consume
resources trying to figure out if you have swap yet -- I'm not convinced
of the veracity of these claims, and lack the time or familiarity with
the current Linux kernel tree to verify for myself.

One thing I will say is that on a server that is in danger of thrashing,
it *can* be preferable to simply have no swap and let the OOMkiller do
its dirty business entirely in core.  This gets you an OOMkilled system
that is still responsive, and if there hasn't been some confusion you
can usually SSH in and restore normal operation quickly.  Contrast this
to swap thrashing followed by the OOMkiller: you're generally stuck with
a reboot at that point, and downtime is bounded by your hardware's POST.

In fact, I've found that on machines that are running horrible PHP
systems[1], the OOMkiller is uncannily accurate: it'll kill off apache
worker processes until it hits the right one, and the master is usually
left unscathed.  Kind of distressing to rely on the OOMkiller like this,
but it's a little more distressing to rely on PHP as far as I'm
concerned.

-- 
Schrödinger's cat was an observer.
WAKE UP, SHEEPLE!  Stop the silence!

1: Eugh, there's a *special* DMZ for that crap, believe me -- too many
   people rely on eval() and importing code from http URLs and
   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA



More information about the buug mailing list