Apache/PHP Lagging badly - Server does not appear to be overloaded
Ok, I have a Dell Dual Processor 2.0GHZ Xeon, 1GB ECC RAM, 2x73GB SCSI drives server that has been chugging along and running perfect for the past few months.A couple of days ago users started reporting to me that pages were 'hanging' and they would have to refresh multiple times and wait a while to get into the site. I did some investgating, watched my server loads, looked at logs etc and couldn't find any problems.
I've pretty much figured out that for some reason about 60% of the time any page I have is hanging when it gets to a php script. At that point it will freeze and either no display, or take a very long time to display.
Static pages, and webhost manager, cpanel scripts etc seem to be running at regular speed, as well as e-mail and FTP which makes this more confusing!
I do not think my server is overloaded, because if you look below on my TOP my cpu's are hardly being used (its a dual cpu, but for some reason redhat 7.3 detects it as quad, rackshack said this was normal), and barely any swap memory is being used.
But what you can also see is that httpd proccesses are hanging around for 1, 2 or 3 minutes. I'm assuming these are the processes where php has hung.
Ive configured apache httpd.conf and added more servers, more max users and all that good stuff, nothing helped. Upgraded my kernel to latest redhat 7.3, nothing helped.
Reduce the timeout times in sysctl.conf, and optimized my my.cnf (even tho it happens to all php pages, not just mysql driven sites)!
Can anyone offer me some insite? This is really annoying some of my users and I can find no solution. It seems to do it more when the server is under load, but my server load hasn't even gone up when this problem came.
One other thing, when I run netstat there are like 500 TIME_WAIT connections, and I'm sure that means something, but I'm not a super linux guru so I don't know what. can anyone help please or give me some more ideas on how to diagnose the problem. Im having another 1gb of ram added to the server just to be on the safe side, but since I dont think its a resource problem in the first place I doubt that will fix it!!
9:29pm up 5:00, 1 user, load average: 0.46, 0.88, 0.75
132 processes: 131 sleeping, 1 running, 0 zombie, 0 stopped
CPU0 states: 4.0% user, 5.0% system, 0.0% nice, 90.0% idle
CPU1 states: 0.1% user, 1.0% system, 0.0% nice, 98.0% idle
CPU2 states: 0.1% user, 2.0% system, 0.0% nice, 97.0% idle
CPU3 states: 2.0% user, 1.1% system, 0.0% nice, 95.1% idle
Mem: 1030676K av, 938392K used, 92284K free, 0K shrd, 93936K buff
Swap: 2048276K av, 3072K used, 2045204K free 687476K cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
8 root 14 0 0 0 0 SW 4.4 0.0 5:08 kscand
29930 nobody 12 0 8188 8188 3464 S 3.4 0.7 0:01 httpd
30312 nobody 13 0 7344 7344 3324 S 1.9 0.7 0:00 httpd
28087 mysql 12 0 15204 14M 2136 S 1.4 1.4 0:03 mysqld
29944 nobody 10 0 7076 7076 3312 S 1.4 0.6 0:01 httpd
29933 nobody 11 0 7088 7088 3312 S 0.9 0.6 0:01 httpd
29938 nobody 10 0 6972 6972 3328 S 0.9 0.6 0:01 httpd
29950 nobody 11 0 7028 7028 3312 S 0.9 0.6 0:00 httpd
30284 nobody 10 0 7028 7028 3328 S 0.9 0.6 0:00 httpd
31079 root 13 0 1004 1004 760 R 0.9 0.0 0:00 top
2312 named 10 0 4268 4268 908 S 0.4 0.4 0:07 named
29954 nobody 10 0 7092 7092 3308 S 0.4 0.6 0:01 httpd
29956 nobody 10 0 8900 8900 3444 S 0.4 0.8 0:01 httpd
1 root 4 0 112 88 56 S 0.0 0.0 0:04 init