Apache: Menghitung Max Client: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
Created page with ""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: determ..."
 
Onnowpurbo (talk | contribs)
No edit summary
 
Line 1: Line 1:
"You can, and should, control the MaxClients setting so that your server does not spawn   
"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  
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  
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  
as top, and divide this into your total available memory, leaving some room for other  
processes."
processes."


Get the Apache process average size:


ps -ylC apache2 --sort:rss


up vote
S  UID  PID  PPID  C PRI  NI  RSS    SZ WCHAN  TTY          TIME CMD
6
S    33  6233 25895  0  80  0  7432 72802 poll_s ?        00:00:00 apache2
down vote
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


Complementing @Sameer answer, I read a lot of this theme and what I do is this:
As you can see in the SZ column my Apache process size is about 73 MB


    Get the Apache process average size:
Make the following formula


    server# ps -ylC apache2 --sort:rss
MaxClients: ((Total_Memory)(1024)(MB) - Other_processes_memory) / 73


    S  UID  PID  PPID  C PRI  NI  RSS    SZ WCHAN  TTY          TIME CMD
For Example: I have 16 GB RAM, I might leave free 2 GB for any other processes
    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
MaxClients: ((16*1024) - 2048) / 73
 
MaxClient: 196  
    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.
This is what I use & my server is going great.

Latest revision as of 09:36, 11 December 2018

"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