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 !!!

Comments

  1. here on 3 line of script you get size that mysql using...
    but 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

    ReplyDelete
  2. Thanks for your sharing!

    ReplyDelete

Post a Comment

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

How to echo colored text in linux shell script: