Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] mysqld invoked oom-killer
Date: Thu, 21 Jul 2011 20:43:42
Message-Id: 2564388.HTsbp6cua7@nazgul
In Reply to: Re: [gentoo-user] mysqld invoked oom-killer by Grant
1 On Thursday 21 July 2011 09:39:52 Grant did opine thusly:
2
3 > > My personal rule of thumb: if you hit swap, the bad thing has
4 > > already gone very very south, usually to the point where you
5 > > can't do much about it and it's already too late. Besides, that
6 > > bastard deomon spawn of satan called the oom-killer is likely
7 > > about to kick in and REALLY make your day. Anyone else notice
8 > > how oom-killer seems to be hard coded to zap the most
9 > > inconvenient process of all?.....
10 > >
11 > > What you need to be doing is monitor your memory usage during
12 > > normal conditions and deal with issues before they become
13 > > problems.
14 >
15 > Hi Alan, I think it was your advice I took a long time ago when I
16 > stopped installing new machines with a swap partition and disabled
17 > it on my already-installed machines. Some time later, others on
18 > this list caught wind of what I'd done and told me I was an idiot.
19 > Is there a consensus on this? If the drawbacks and advantages of
20 > using swap cancel each other out, I won't use it.
21
22 I would strongly advise you to make your own measurements and heed
23 your own counsel. I can only speak from my own experience, and I may
24 well be speaking a whole load of codswallop. Or I may be right and the
25 opposing view is wrong. Who's to tell?
26
27 My own experience with backing swap has been almost uniformly bad,
28 especially on machines running Apache and MySQL due to the massive
29 performance hit it invariably causes. I see memory as a finite
30 resource - you only have so much of it, so use it wisely and stay away
31 from using all of it up.
32
33 The oom killer is also a point of contention. The algorithm is
34 designed to try and detect the best pid to kill in order to keep the
35 machine up, but there is no measurement for "least important process".
36 So instead it has to infer it from time last used, time running and
37 various other bits. These assumptions can never be 100% right.
38
39 I believe the best solution to running out of memory is well-written
40 apps that degrade or die gracefully when they hit out of memory
41 conditions. I always thought Apache was rather good at this, it would
42 simply kill of the child process and deliver an error. You seem to
43 have found a way round this :-)
44
45 kashani's advice seems reasonable, tune your machine to suit it's
46 load. We've established that the problem was a client hitting your
47 webserver 300 times in a minute. That is a DOS, so the solution would
48 be to find a way to configure Apache to detect abuse like this and not
49 deliver the page.
50
51 But back to swap. I have two cases where it is rather useful. This
52 notebook uses swap for image storage when hibernating, and my Sybase
53 database servers at work use swap well, retrieving data pages from
54 swap is faster than searching through the database indexes for where
55 they are, simply because the kernel alredy knows exactly where the
56 swapped data is on disk. But this is a niche circumstance and in no
57 way representative of a typical Linux machine's behaviour.
58
59 Summary: Do your own tests, make your own conclusions and vigorously
60 defend them.
61
62 Sorry for the complete lack of a definitive answer, we are victims of
63 TheRealWorldOutThere(tm)
64
65
66 --
67 alan dot mckinnon at gmail dot com

Replies

Subject Author
Re: [gentoo-user] mysqld invoked oom-killer Grant <emailgrant@×××××.com>