Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommended max value for Max Connections Per Child in Apache configuration?

I am traying to reduce memory usage by Apache on the server.

My actual Max Connections Per Child is 10k

According to the following recommendation

the Max Connections Per Child should be reduced to 1000

http://www.lophost.com/tutorials/how-to-reduce-high-memory-usage-by-apache-httpd-on-a-cpanel-server/

What is the recommended max value for Max Connections Per Child in Apache configuration?

like image 648
RafaSashi Avatar asked Mar 29 '14 15:03

RafaSashi


People also ask

What is Apache max connection limit?

Apache2 defaults to only allowing 150 concurrent connections. NGINX can handle a maximum of 512 concurrent connections. In newer versions, NGINX supports up to 1024 concurrent connections, by default.

How many requests can Apache handle per second?

By default, Apache Request limit is 160 requests per second, that is, Apache can handle up to 160 requests per second, without any modification.

How many threads can Apache handle?

Apache comes with 40-100 max threads. It can be increased to allow more threads to be handled at the same time. The application should be monitored before making any changes to it. Based on the response, try to change "ThreadsPerChild" and "AcceptThreads" accordingly.

What is the directive that can be used to set the limit on the maximum number of clients to be connected to the server?

The MaxConnectionsPerChild directive sets the limit on the number of connections that an individual child server process will handle.


2 Answers

The only time when this directive affects anything is when your Apache workers are leaking memory. One way this happens is that memory is allocated (via malloc() or whatever) and never freed. It's the result of design/implementation flaws in Apache or its modules.

This directive is somewhat of a hack, really -- but if there's some module that's loaded into Apache that leaks, say, 8 bytes every request, then after a lot of requests, you'll run out of memory. So the quick fix is to just kill the process every MaxConnectionsPerChild requests and start a new one.

This will only affect your memory usage if you see it gradually increase over the span of lots of requests when setting MaxConnectionsPerChild to zero.

like image 56
Hut8 Avatar answered Sep 22 '22 00:09

Hut8


The default is 0 (which implies no maximum connections per child) so unless you have memory leakage I'm unaware of any need to change this setting - I agree with Hut8.

Sharing here FYI from the Apache 2.4 Performance Tuning page:

Related to process creation is process death induced by the MaxConnectionsPerChild setting. By default this is 0, which means that there is no limit to the number of connections handled per child. If your configuration currently has this set to some very low number, such as 30, you may want to bump this up significantly. If you are running SunOS or an old version of Solaris, limit this to 10000 or so because of memory leaks.

And from the Apache 2.4 docs on MaxConnectionsPerChild:

Setting MaxConnectionsPerChild to a non-zero value limits the amount of memory that process can consume by (accidental) memory leakage.

like image 39
user12345 Avatar answered Sep 22 '22 00:09

user12345