Httpd – MaxClients in apache. How to know the size of the proccess

apache-2.2httpd

From http://httpd.apache.org/docs/2.2/misc/perf-tuning.html

The single biggest hardware issue affecting webserver performance is
RAM. A webserver should never ever have to swap, as swapping increases
the latency of each request beyond a point that users consider "fast
enough". This causes users to hit stop and reload, further increasing
the load. You can, and should, control the MaxClients setting so that
your server does not spawn so many children it starts swapping. This
procedure for doing this is simple: determine the size of your average
Apache process, by looking at your process list via a tool such as
top, and divide this into your total available memory, leaving some
room for other processes.

The main issue is that I can't understand how to know the size, because, well i have the size of httpd on no more of 3888

But, if we need to determine the number for MaxClients, and I have 4GB of RAM, so I get: 972, so I should use like 900 in the MaxClients?

Best Answer

First, determine the PID of one of your Apache processes.

Then you can do something like this:

cat /proc/PIDHERE/status | grep VmRSS

This will yield the (current) resident-set-size of that particular process, similar to:

VmRSS: 304456 kB

This value is as it sounds, it is the size of the process resident in RAM.

Then normalize your unit of measure (4GB * 1024 * 1024 = 4,194,304 KB). Divide:

4194304 KB / 304456 KB = 13.77 processes

Consider that you probably have other processes running on your system that will consume memory too, and ideally you want to minimize swapping, therefore you would not likely want 13 Apache MaxClients configured (using my numbers), you want some amount less (at your discretion).

This is a crude estimate; the size of your Apache processes may grow over time depending on load.