Forum Moderators: phranque
Assume the hits at peak time is 100,000/hour. And then 100,000 / (60 * 60) = 27 right. But according to "netstat -an ¦ grep -c :80", usually I have more than 300 httpd connections, 500 httpd connections at peak time and more than 200 at midnight. The load avg is 1.20 and sometimes under 0.6.
The current MaxClients is 350 and KeepAliveTimeOut is 3. (Sites down if I increase it to 5, btw).
I checked all these 300+ connections randomly and they are all look good. So how does this happen? Why there are so many httpd connections?
Another strang thing is, the average Visitors vs Hits value of my websites is 1:3.5, but one site's value is 1:11, which is very strange to me. This site is not popular at all.
Please let me know how I can underdtand this problem!
You could use mod_status which serves a status page of the Apache server with information about the server health. This includes the number of open, but currently unused connections which are kept alive. Tune your KeepAliveTime setting in such a way that there is a reasonable amount of working / idle services.
Do you serve many graphics or external JavaScript files to the visitors? If you only serve a PHP page with very few extra files (image or js), you could try to turn the KeepAlive setting off. In that case every httpd will be free for a new connection as soon as the previous transfer has ended. This will increase the number of seperate connections and when you serve many separate files per page it will slow down the download to the visitor's PC, but it will decrease the idle time of the processes on your server and in your case reduce the number of concurrently running httpd daemons.
If you are serving a lot of graphics which would hurt download speed when you switch the KeepAlive setting to off, consider sending expire headers with mod_expires for your "site furniture". Browsers will download those static files only once and not recheck with an If-modified-since header if the visitor surfs to another page. This can reduce the amount of single requests to your server dramatically, depending on the number of seperate files per pageview. It won't reduce bandwidth that much but reduces the number of requests. This is especially a good option if you find a lot of 304 responses (not modified) in your apache log files.