Apache: Menghitung Max Client

From OnnoWiki
Jump to: navigation, search
"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."

Get the Apache process average size:

ps -ylC apache2 --sort:rss
S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S    33  6233 25895  0  80   0  7432 72802 poll_s ?        00:00:00 apache2
S    33  6250 25895  0  80   0  7432 72802 poll_s ?        00:00:00 apache2
S    33  6278 25895  0  80   0  7432 72802 poll_s ?        00:00:00 apache2  
S    33  6280 25895  0  80   0  7432 72802 poll_s ?        00:00:00 apache2 
S    33  6577 25895  0  80   0  7432 72802 poll_s ?        00:00:00 apache2
S    33  6299 25895  0  80   0  7772 72891 poll_s ?        00:00:00 apache2
S    33  6295 25895  0  80   0  7776 72891 poll_s ?        00:00:00 apache2

As you can see in the SZ column my Apache process size is about 73 MB

Make the following formula

MaxClients: ((Total_Memory)(1024)(MB) - Other_processes_memory) / 73

For Example: I have 16 GB RAM, I might leave free 2 GB for any other processes

MaxClients: ((16*1024) - 2048) / 73
MaxClient: 196 

This is what I use & my server is going great.

You have to consider that my Apache processes are a little heavy, so you could have processes about 50 MB or less.

Regards,

Your SZ is slightly the same for all Apache processes. In my case I have values between 23 and 212 Mb

enter image description here

What value should I use in your formula ?

By the way in Apache 2.4 MaxClients has been renamed to MaxRequestWorkers. Is your formula still valid for this new parameter ?

Regards


Pranala Menarik