1 |
On Sun, Sep 16, 2012 at 9:26 AM, Michael Hampicke <gentoo-user@××××.biz> wrote: |
2 |
> Am 16.09.2012 08:55, schrieb Jarry: |
3 |
>> Hi, |
4 |
>> strange thing happened to my web-server (apache-2.2.22-r1): |
5 |
>> it started forking untill it used all ram/swap and stopped |
6 |
>> responding. I counted ~60 apache processes running (ps -a), |
7 |
>> all sleeping, top showed no load except all memory being used. |
8 |
>> Log-files showed nothing suspicious to me, except for a few |
9 |
>> "GET / HTTP/1.1 200 40" messages at the time when apache |
10 |
>> was already unable to send reply. |
11 |
>> |
12 |
>> Apparently my apache is not correctly configured when it |
13 |
>> "forked to death", but maybe someone can help me. I have |
14 |
>> about 1GB memory for apache. What should I change in my |
15 |
>> config so that apache never runs out of memory? |
16 |
>> |
17 |
>> server-info: |
18 |
>> Timeouts: connection: 60 keep-alive: 15 |
19 |
>> MPM Name: Prefork |
20 |
>> MPM Information: Max Daemons: 150 Threaded: no Forked: yes |
21 |
>> Module Name: prefork.c |
22 |
>> 31: StartServers 5 |
23 |
>> 32: MinSpareServers 5 |
24 |
>> 33: MaxSpareServers 10 |
25 |
>> 34: MaxClients 150 |
26 |
>> |
27 |
>> Jarry |
28 |
>> |
29 |
> |
30 |
> |
31 |
> Hi, |
32 |
> |
33 |
> try reducing MaxClients to 64, StartServers and MinSpareServers to 2 and |
34 |
> then observe how things develop. If you then feel apache is to slow to |
35 |
> respond to request under load, try increasing MinSpareServer one at a |
36 |
> time. But always keep in mind: every fork of apache eats your memory. |
37 |
|
38 |
And sucks up system entropy. And increases connection latency, if |
39 |
you've already got a request waiting on that fork to spin up. |
40 |
|
41 |
I have StartServers, MinSpareServers, MaxSpareServers and MaxClients |
42 |
all pegged to the same value. And on the server in question, they'll |
43 |
all pegged to '10'. |
44 |
|
45 |
I have MaxRequestsPerChild set to 20000, so that any leaky processes |
46 |
get cleaned up. |
47 |
|
48 |
Because I need to fit a lot of operation into a limited space, I need |
49 |
to be able to reasonably predict how much RAM is going to be in use by |
50 |
each of my services. A "MaxClients" of 10 may seem small, but that's |
51 |
what Squid is for; only requests Squid couldn't cache get passed on to |
52 |
Apache. |
53 |
|
54 |
The server I'm describing is a VM with 4GB of RAM, and is also running |
55 |
MySQL, squid and memcached. For those playing with the numbers in |
56 |
their head, each of these numbers reflect RES (code+data resident in |
57 |
RAM): |
58 |
|
59 |
* Each Apache process is consuming 80-100MB of RAM. |
60 |
* Squid is consuming 666MB of RAM |
61 |
* memcached is consuming 822MB of RAM |
62 |
* mysqld is consuming 886MB of RAM |
63 |
* The kernel is using 110MB of RAM for buffers |
64 |
* The kernel is using 851MB of RAM for file cache (which benefits squid). |
65 |
|
66 |
And, not RAM, but potentially of interest for the curious: |
67 |
* The MySQL db is consuming 3.8GB on disk. |
68 |
* The Squid cache is about 9.2GB on disk. |
69 |
|
70 |
|
71 |
-- |
72 |
:wq |