You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jonathan Cutting <jo...@blaxhall.com> on 2009/07/26 10:05:40 UTC

[users@httpd] MaxRequestsPerChild and MaxKeepAliveRequests clarification

Hi all,

I'm running Apache 2.2.9 on a machine with 4G of RAM, and the server 
experiences about 100,000 hits a day, ~1G bandwidth and about 30,000 
page requests.

It's running several instances of a large PHP web app so there are 
comparatively few users who between them request many pages each.

I'm trying to work out the optimal settings for the server - I used to 
have MaxRequestsPerChild set to 2000 and MaxKeepAliveRequests at 300 - 
but the server started swapping towards the end of each day.

I read somewhere that when the MaxKeepAliveRequests directive is set, 
each server will actually serve MaxKeepAliveRequests multiplied by 
MaxRequestsPerChild before it dies - which in my case was 600,000 
requests. Is this indeed correct? I'm keen to make the best use of the 
memory but at present have set MRPC down to 300 and memory use has 
stabilised. Any advice on the optimal balance between the two settings 
would be very much appreciated,

thanks, Jon.

Current apache2.conf:

MaxKeepAliveRequests 300

KeepAliveTimeout 15

<IfModule mpm_prefork_module>
     StartServers             8
     MinSpareServers          6
     MaxSpareServers         15
     MaxClients             256
     MaxRequestsPerChild    300
</IfModule>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] MaxRequestsPerChild and MaxKeepAliveRequests clarification

Posted by Jonathan Cutting <jo...@blaxhall.com>.
Nick,

many thanks for your response. I'm running xcache on the server and it 
uses about 1.5G of the 4G memory caching all the php scripts, so Apache 
isn't using quite as much memory as it might seem at first. There are 
not many images but each request can include up to 100 php scripts.

On 26/07/09 14:49, Nick Kew wrote:
> Jonathan Cutting wrote:
>> Hi all,
>>
>> I'm running Apache 2.2.9 on a machine with 4G of RAM, and the server 
>> experiences about 100,000 hits a day, ~1G bandwidth and about 30,000 
>> page requests.
>
> That's about 100 times more memory than you should need for the load :)
>
>> It's running several instances of a large PHP web app so there are 
>> comparatively few users who between them request many pages each.
>>
>> I'm trying to work out the optimal settings for the server - I used 
>> to have MaxRequestsPerChild set to 2000 and MaxKeepAliveRequests at 
>> 300 - but the server started swapping towards the end of each day.
>
> You have a problem.  That's an extremely low MaxRequestsPerChild.
> Sounds like you may have a BIG memory leak!
>
>> I read somewhere that when the MaxKeepAliveRequests directive is set, 
>> each server will actually serve MaxKeepAliveRequests multiplied by 
>> MaxRequestsPerChild before it dies - which in my case was 600,000 
>> requests. Is this indeed correct?
>
> No.  MaxRequestsPerChild should actually read MaxConnectionsPerChild.
> But the keepalives is something you'll hit much more rarely, unless
> one of your PHP pages generates several thousand hits to images,
> stylesheets, etc.  A mere 300 could only generate that many keepalive
> requests if a browser confined itself to a single connection - which
> AFAIK no mainsteam browser has done since Netscape 0.9 implemented
> parallel connections in (IIRC) 1994.
>

Ah ok, so a browser will make a few connections to the server and even 
if the page includes say 40 images and 10 js scripts, the keepalive 
total per child will be pretty low, possibly ~10 requests. I've used 
mod_expires to set pretty aggressive browser caching so in most cases 
there should only be some html served.

>>   I'm keen to make the best use of the memory but at present have set 
>> MRPC down to 300 and memory use has stabilised. Any advice on the 
>> optimal balance between the two settings would be very much appreciated,
>
> Find out what's leaking memory.
>
> You might also benefit from swapping to a threaded MPM (e.g. worker)
> and run your PHP under fastcgi with mod_fcgid.  That way you could
> also raise your MaxClients, which looks very, very low, and
> drop all use of MaxRequestsPerChild.
>

Even at very busy times, the server is only running about 35 children - 
there are about 400 users who access the server sporadically throughout 
the day (some more intensively than others). Looks like I need to spend 
some time figuring out how each child's memory usage grows and why, and 
testing a server using fastcgi.

Thanks again,

Jonathan








---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] MaxRequestsPerChild and MaxKeepAliveRequests clarification

Posted by Nick Kew <ni...@webthing.com>.
Jonathan Cutting wrote:
> Hi all,
> 
> I'm running Apache 2.2.9 on a machine with 4G of RAM, and the server 
> experiences about 100,000 hits a day, ~1G bandwidth and about 30,000 
> page requests.

That's about 100 times more memory than you should need for the load :)

> It's running several instances of a large PHP web app so there are 
> comparatively few users who between them request many pages each.
> 
> I'm trying to work out the optimal settings for the server - I used to 
> have MaxRequestsPerChild set to 2000 and MaxKeepAliveRequests at 300 - 
> but the server started swapping towards the end of each day.

You have a problem.  That's an extremely low MaxRequestsPerChild.
Sounds like you may have a BIG memory leak!

> I read somewhere that when the MaxKeepAliveRequests directive is set, 
> each server will actually serve MaxKeepAliveRequests multiplied by 
> MaxRequestsPerChild before it dies - which in my case was 600,000 
> requests. Is this indeed correct?

No.  MaxRequestsPerChild should actually read MaxConnectionsPerChild.
But the keepalives is something you'll hit much more rarely, unless
one of your PHP pages generates several thousand hits to images,
stylesheets, etc.  A mere 300 could only generate that many keepalive
requests if a browser confined itself to a single connection - which
AFAIK no mainsteam browser has done since Netscape 0.9 implemented
parallel connections in (IIRC) 1994.

>   I'm keen to make the best use of the 
> memory but at present have set MRPC down to 300 and memory use has 
> stabilised. Any advice on the optimal balance between the two settings 
> would be very much appreciated,

Find out what's leaking memory.

You might also benefit from swapping to a threaded MPM (e.g. worker)
and run your PHP under fastcgi with mod_fcgid.  That way you could
also raise your MaxClients, which looks very, very low, and
drop all use of MaxRequestsPerChild.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org