• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Apache2 won't close children & eats memory

P

Peter Hase

Guest
Hi Forum,

I looked through the forum here and used google to try to find an answer to my problems:
I recently migrated to a new VPS with my previous plesk installation via the migration manager (Plesk 10.4 to 10.4, sam os, same version: Ubuntu 10.04 LTS).

Now my Apache web server is configured for consuming the least amount of ram and cpu resources, at least I hope to. I monitor it with the plesk health monitor.

My apache2.conf looks like this (in the important parts):

# Timeout: The number of seconds before receives and sends time out.
#
Timeout 10

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 500

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 7
ServerLimit 30
MaxClients 30
MaxRequestsPerChild 500
</IfModule>

What happens is that the process spawn children, but doesn't close them - the memory just slowly slowly groes. Like a memory leak, but I don't know where it comes from. I tried to minimize the number of mods used and disabled SSL in all my vhosts. I am using stock configured mysql and php5.

Here is what apache2ctl fullstatus tells me when I run it twice shortly after another:

Restart Time: Wednesday, 28-Mar-2012 13:16:07 CEST
Parent Server Generation: 1
Server uptime: 23 minutes 39 seconds
Total accesses: 321 - Total Traffic: 12.4 MB
CPU Usage: u21.6 s2.59 cu0 cs0 - 1.7% CPU load
.226 requests/sec - 9.0 kB/second - 39.7 kB/request
1 requests currently being processed, 6 idle workers

____W_._......................


Current Time: Wednesday, 28-Mar-2012 13:39:59 CEST
Restart Time: Wednesday, 28-Mar-2012 13:16:07 CEST
Parent Server Generation: 1
Server uptime: 23 minutes 51 seconds
Total accesses: 322 - Total Traffic: 12.4 MB
CPU Usage: u21.6 s2.59 cu0 cs0 - 1.69% CPU load
.225 requests/sec - 8.9 kB/second - 39.6 kB/request
1 requests currently being processed, 6 idle workers

___W__._......................

These is what the idle childs are doing (according to apache2ctl and without personal details):
4-1 30117 0/3/12 _ 0.00 11 0 0.0 0.01 0.02 127.0.0.1
<generic vps host> GET /server-status HTTP/1.0
11-0 - 0/0/33 . 13.34 621 0 0.0 0.00 0.30 127.0.0.1
<generic vps host> GET /server-status HTTP/1.0
12-0 - 0/0/26 . 1.39 621 0 0.0 0.00 1.36 127.0.0.1
<generic vps host> GET /server-status HTTP/1.0
13-0 - 0/0/24 . 1.13 621 19 0.0 0.00 1.91 72.14.199.202
<actual vhost configured> GET /feed HTTP/1.1

Does anybody have an idea what is going on here?
 
kinda solved...

I singled out the culprit: It was PHP!
I was fiddling with all kinds of Apache2 settings, but didn't resolve the issue. Then I switched from mod_php to fastcgi php and bam, the problems vanished.
Now apache2 takes around 16MB ram instead of up to 600MB and the php5-cgi children kill themselves as they should after the designated timeout.
The initial loading of a page takes a bit longer, but that is a ok for me.

So, I guess, the problem of the mem leak and and bad php script somewhere isn't solved, but at least switching the php module helped me a lot. for now.
 
Back
Top