PDA

View Full Version : Apache loads up the server.. help!


CooLMaN
06-27-2004, 06:15 AM
Hey guys,
i got my new Dual P3 800MHz + 512MB ram server ( with DA installed and FC1 ).

I recompiled apache ( using da script ), and also installed ZEND ( thought it seems like dosent do anything ), also installed mod_gzip ( and verified its working ), but server loads go often to 15 and when i check its says httpd uses 99% cpu.. and i got very low memory when apache is running .

here is my httpd important lines:
Timeout 300
KeepAlive off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 8
MaxClients 300
MaxRequestsPerChild 0


please tell me what to add/remove/fix.

thank you all,
gil.

DirectAdmin Support
06-27-2004, 01:10 PM
Hello,

I'm not too sure.. it could be a rogue cgi script, or a bad compile. Check the username that is being used for the apache process that is eating up your cpu. If it's apache, then it might be a php script, if it's a DA user, it might be a cgi (although cgi's are run on their own). If it's running as root, then it's the parent process going nuts, so a clean rebuild might be needed. Not sure that it would be the problem, but it's something to try:
cd /usr/local/directadmin/customapache
./build clean
./build all
/sbin/service httpd restartJohn

CooLMaN
06-27-2004, 01:22 PM
thank you John,
My dc says i need more ram, thought its way too expensive.

Can you give me a good httpd.conf configurations?



Thanks!
gil.

DirectAdmin Support
06-27-2004, 01:36 PM
Timeout 300
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 8
MaxClients 300
MaxRequestsPerChild 10000

The only real performance increase would be the "KeepAlive on". It allows multiple requests to be made through the same apache connection. The MaxRequestsPerChild can be 0, I just like to set it to a high number so that the child process is restarted every now and then in case there are any memory leaks (not too likely)

John

CooLMaN
06-27-2004, 02:11 PM
Thanks!

jlasman
06-27-2004, 05:01 PM
Originally posted by CooLMaN
My dc says i need more ram, thought its way too expensive.
Half a gig of RAM should be enough, but I've never felt RAM to be too expensive considering the benefits.

Our system minimum installs are now 1 gig of RAM.

Jeff

Wunk
07-13-2004, 05:00 AM
Take into account that this can be a simple case of ****ty PHP programming..

See in top if it's httpd loading up your server, and if so, what you can do to find the problem site is the following:

ps aux | grep httpd
see if there's a ****load of httpd/apache processes running..., look at their PID's and the time that they were started, this is a good starting point.., note these 2 things down

Now it's time for the tedious part.., log digging..

First look in /var/log/httpd/suexec_log, and look the time up, and see if some weird scripts got executed.., if not, time to dig the user logs..

Since it's usually PHP which causes this, we can already narrow it down to only PHP scripts at those minutes the bunch of httpd processes were running as..

Example:
cd /var/log/httpd/domains
grep "12/Jul/2004:15:28" * | grep php | less

This line will display every entry from July 12th on 15:28 with the word php in it.., it's still a ****ty job to find WHICH exact domain and script is giving the problems, but you can narrow down the suspects now..


If you have a suspect and it happens often, you could add the following to his/her httpd.conf:
CustomLog "| /var/log/httpd/access_pid_log 86400" "%v|%f|%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %P"

This will create a file /var/log/httpd/access_pid_log with all entries for that domain AND the process ID of the httpd process serving the request at the end, so you can see which httpd process got stuck, and if it was that domain/script causing it..