Apache leaking memory - tips on how to find the problem?

Apache leaking memory - tips on how to find the problem?

am 21.09.2009 06:34:13 von Steve

--001485f3357064a64e04740efef4
Content-Type: text/plain; charset=ISO-8859-1

Hello everyone,

My prefork apache configuration is causing processes to leak lots of memory.
I'm hoping people on this list could suggest ways in me finding it, given
that I've been unsucessful in isolating the problem.

Here is a breakdown of my configuration:

Ubuntu 9.04 with 2.6 Kernel
Apache 2.2.11 with enabled modules:
Alias
Authz_Host
AutoIndex
Deflate
Dir
expires
headers
mime
Status
PHP 5.2.6-3ubuntu4.2 with Suhosin-Patch 0.9.6.2 with modules:
curl
gd2
pdo
pgsql (using PostgreSQL 8.3.7 on the same system)
This runs on a fairly beefy dual quad-core Xenon Server with terabytes of
HD and 12 GB of RAM.
My website gets miminal traffic at the moment (average 5 users
simulatenously throughout the day) and yet I find I run out of memory in
less than 24 hours, I have a cron which restarts the server to band-aid the
problem. Whatever I'm leaking, I'm leaking fast - htop shows my RAM on
average going up roughly between 2-4 MB/s depending on the request, and it's
all in apache processes. I seemed to have slowed down the problem by
re-configuring my conf like so:


StartServers 50
MinSpareServers 20
MaxSpareServers 50
ServerLimit 1500
MaxClients 1500
MaxRequestsPerChild 1000


Which is only a temporary solution, because I except traffic to increase
from this point forward. Since my website uses ajax heavily for polling it's
worth mentioning that I have my keep-alives set very tightly as well:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 15

I do not use persistant connections between Postgres and PHP since I found
it aggrevated the problem horrendously. I've tried to get a memory map a
particular process, using pmap, but I always get 0k result:

pmap -x 12762
12762: /usr/sbin/apache2 -k start
Address Kbytes RSS Anon Locked Mode Mapping
-------- ------- ------- ------- -------
total kB 0 - - -

I've also attempted exmap, which was installed from apt as gexmap, but all I
get from is this error which I haven't found a solution that works for me:

(gexmap:14395): Gtk-WARNING **: cannot open display:

Can anyone suggest a strategy on how to isolate what exactly is going on
inside these processes and why they absorb such huge chunks of RAM? Any
advice would be appreciated.

Regards,
Steve

--001485f3357064a64e04740efef4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello everyone,

My prefork apache configurati=
on is causing processes to leak lots of memory. I'm hoping people on th=
is list could suggest ways in me finding it, given that I've been unsuc=
essful in isolating the problem.



Here is a breakdown of my configuration:

=
Ubuntu 9.04 with 2.6 Kernel
:pre"> Apache 2.2.11 with enabled modules:

Alias
=3D"white-space:pre"> Authz_Host
ce:pre"> AutoIndex

Deflate
=3D"white-space:pre"> Dir
> expires

headers
=3D"white-space:pre"> mime
"> Status

PHP 5.2.6-3ubuntu4.2 with Suh=
osin-Patch 0.9.6.2 with modules:
=
curl
gd2 >

pdo
"white-space:pre"> pgsql (using PostgreSQL 8.3.7 on the same syste=
m)

This runs on a fairly beefy dual quad-core Xenon Server with terabytes=
of HD and 12 GB of RAM.
n>
My website gets miminal traffic at the moment (average 5 users=
simulatenously throughout the day) and yet I find I run out of memory in l=
ess than 24 hours, I have a cron which restarts the server to band-aid the =
problem.=A0Whatever I'm leaking, I'm leaking fast - htop shows my R=
AM on average going up roughly between 2-4 MB/s depending on the request, a=
nd it's all in apache processes. I seemed to have slowed down the probl=
em by re-configuring my conf like so:



<IfModule mpm_prefork_module>
   =
=A0StartServers =A0 =A0 =A0 =A050
   =A0MinSpareServers =A0 =
=A0 20
   =A0MaxSpareServers =A0 =A0 50
   =A0S=
erverLimit =A0 =A0 =A0 =A0 1500
   =A0MaxClients =A0 =A0 =A0 =
=A0 =A01500


   =A0MaxRequestsPerChild 1000
</IfModule>
iv>
Which is only a temporary solution, because I except traf=
fic to increase from this point forward.=A0Since my website uses ajax heavi=
ly for polling it's worth mentioning that I have my keep-alives set ver=
y tightly as well:



Timeout 300
KeepAlive On
MaxKeepAli=
veRequests 0
KeepAliveTimeout 15

I do no=
t use persistant connections between Postgres and PHP since I found it aggr=
evated the problem horrendously.=A0I've tried to get a memory map a par=
ticular process, using pmap, but I always get 0k result:



pmap -x 12762
12762: =A0 /usr/sbin/apache2 -k=
start
Address =A0 Kbytes =A0 =A0 RSS =A0 =A0Anon =A0Locked Mode =
=A0 Mapping
-------- ------- ------- ------- -------
to=
tal kB =A0 =A0 =A0 0 =A0 =A0 =A0 - =A0 =A0 =A0 - =A0 =A0 =A0 -



I've also attempted exmap, which was installed from=
apt as gexmap, but all I get from is this error which I haven't found =
a solution that works for me:=A0

(gexmap:14395): G=
tk-WARNING **: cannot open display:



Can anyone suggest a strategy on how to isolate what ex=
actly is going on inside these processes and why they absorb such huge chun=
ks of RAM? Any advice would be appreciated.

Regard=
s,


  Steve


--001485f3357064a64e04740efef4--