Monday, March 25, 2013

"Reached max clients" error in web server?

Verify the error in err_log file, it shows the "Reached max clients" error.
 If you found this error verify how many http process are running
                                # ps -ef|grep -c httpd|wc -l
                                #17
Open the httpd.conf file and verify the the maxClients is 16.

So web server reached max clients , for that it thrown the "Reached max clients" error in web server?

Solution:
Step 1:Find out the how much memory on avg each http process is using

                       #top -b -c -n 1|grep httpd|awk '{print $6}'
                       #18m
                         18m
                         18m
                         20m
                         18m
                          15m
                 (or) use below script 

 ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

Avg: 18m

Step 2 : Stop Apache , determine the amount of Free memory available (without running apache)

                     #free -m
                     #total        used    free
                       432        26        405
Step 3: It is good to have at least 20mb of free memory , if apache was running at it max.

                        = free memory - 20mb
                        =385
Step 4:
 
                            free Memory after stopping Apache - 20 mb
     maxClient =  __________________________________
                                   avg http consuming memory

                maxClients = 385/18
                                    =21
                                    =round (21)
                                    =20

So maxClients in httpd.conf is 20

No comments: