Apache MaxClients Calculation
MaxClients:
The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.
For non-threaded servers (i.e., prefork), MaxClients translates into the maximum number of child processes that will be launched to serve requests. The default value is 256; to increase it, you must also raise ServerLimit.
calculating MaxClients value:
#!/bin/bash
tome=$(free -m | grep -i mem | awk '{print $2}')
htps=$(ps -aylC httpd |grep "httpd" |awk '{print $8'} |sort -n |tail -n 1)
mysme=$(ps aux | grep 'mysql' | awk '{print $6}' |sort -n |tail -n 1)
rafa=1024
nmysme=$(expr $mysme / $rafa)
nhtps=$(expr $htps / $rafa)
echo -e "\nTotal Memory = $tome"
echo -e "Largest httpd Process = $nhtps"
echo -e "Mysql Memory = $nmysme"
maxc=`expr $tome - $nmysme`
maxcl=`expr $maxc / $nhtps`
echo -e "\nSo, The MaxClients = $maxcl"
echo -e "(we can use nearest round of value from $maxcl)"
For example, copy the above code in a file named "maxcalc.sh" then
# chmod 755 maxcalc.sh
# ./maxcalc.sh
The output will belike,
Total Memory = 15905
Largest httpd Process = 16
Mysql Memory = 1934
So, The MaxClients = 873
(we can use nearest round of value from 873)
cheers !!!
The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.
For non-threaded servers (i.e., prefork), MaxClients translates into the maximum number of child processes that will be launched to serve requests. The default value is 256; to increase it, you must also raise ServerLimit.
calculating MaxClients value:
#!/bin/bash
tome=$(free -m | grep -i mem | awk '{print $2}')
htps=$(ps -aylC httpd |grep "httpd" |awk '{print $8'} |sort -n |tail -n 1)
mysme=$(ps aux | grep 'mysql' | awk '{print $6}' |sort -n |tail -n 1)
rafa=1024
nmysme=$(expr $mysme / $rafa)
nhtps=$(expr $htps / $rafa)
echo -e "\nTotal Memory = $tome"
echo -e "Largest httpd Process = $nhtps"
echo -e "Mysql Memory = $nmysme"
maxc=`expr $tome - $nmysme`
maxcl=`expr $maxc / $nhtps`
echo -e "\nSo, The MaxClients = $maxcl"
echo -e "(we can use nearest round of value from $maxcl)"
For example, copy the above code in a file named "maxcalc.sh" then
# chmod 755 maxcalc.sh
# ./maxcalc.sh
The output will belike,
Total Memory = 15905
Largest httpd Process = 16
Mysql Memory = 1934
So, The MaxClients = 873
(we can use nearest round of value from 873)
cheers !!!
nice post
ReplyDeletehere on 3 line of script you get size that mysql using...
ReplyDeletebut if my server has other software like apache, activemq, java process
so can i take out memory usages of above software and minus from total ram size
if is it true??
so how can i calculate memory usages for apache, activemq, java process
Thanks for your sharing!
ReplyDeleteAwesome!
ReplyDelete