PDA

View Full Version : looking for help on MaxClients and apache error logs


woodchuck
06-11-2009, 12:38 PM
Hi,

I just moved my site to a virtual private server from a shared environment, so its my first time having this much control. Just what I needed...more responsibility. :eek::confused::D

The VPS has 2.0 GB of memory usage available and I seem to be averaging 225 MB during off hours and just over 300 MB during peak hours during the week. Weekends are busier but I only got this on Monday so that remains an unknown.

While looking in the apache log I seen this yesterday [Wed Jun 10 15:39:37 2009] [error] server reached MaxClients setting, consider raising the MaxClients setting which was preceded in the previous 30 secs of +20 entires of what looks like warnings and errors. As well, before and after that block of data there are 20 or so "Invalid query name 1".

A short conversation with the Tier II tech who moved my site for me he said As far as the MaxClients error, that's an indication of a high level of traffic on the server, causing Apache2 to error out. This can be increased inside of the file '/etc/apache2/apache2.conf'. Do some research on what 'maxclients' means, and increase in small increments, as opening up too many clients can overload the server as a whole, and cause Apache2 to lag, among other anomalies. I looked up in the apache.conf file and see MaxClients = 30 but there are two listed, one under 'prefork MPM' and the other under 'worker MPM'.

I found http://httpd.apache.org/docs/2.0/mod/worker.html and http://httpd.apache.org/docs/2.0/mod/prefork.html and they both seem to do similar functions except one seems do more. I got this from Apache
http://httpd.apache.org/docs/2.0/misc/perf-tuning.html

* The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.
* The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but it uses more memory. Prefork's threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support.

Does it matter which I increase? Or should only one be showing up on the apache.conf file?

As far as I can understand, to determine a proper value for MaxClients, I would have to determine how much memory is consumed by each process and divide that into the total memory available. While also keeping in mind that if Apache and MySQL are running in the same environment, then a chunk of memory should me allocated to MySQL. I've read that half the onboard memory should be set aside for MySQL. The unknown value is how much memory is used by each process. I have no idea what that would be. Would there be something to look at on the server that could determine that?

Any help would be appreciated. Try to keep your explainations in layman's terms if you could. :o Thanks in advance.

schleppel
06-11-2009, 09:06 PM
Multi-Processing Modules (MPMs) (http://httpd.apache.org/docs/2.0/mpm.html).

Does it matter which I increase? Or should only one be showing up on the apache.conf file?
Apache will only be using one MPM, the other configuration set is there so you could use the other MPM. So updating them both won't hurt. I am unsure of how to work out which one you are using.

woodchuck
06-11-2009, 09:15 PM
Ok. thanks.

Next related questions:
Is there some stat to look at that can show how much memory is consumed per process? If not and I slowly increment the MaxClients, let's say +1 per day, what would I be looking to monitor for its effects. I would think it would be difficult to say "monitor if your site is slow to load" because browser load speed is dependant on ISP access for a visitor. So is there a stat or log to monitor for warnings or error msgs? Or am I thinking too much about this? :)

schleppel
06-11-2009, 10:54 PM
Unfortunately i don't know anything about doing that.

Gohnny
06-12-2009, 12:17 PM
woodchuck - I like your post on this error

My application always dies with this error.

[error] server reached MaxClients setting, consider raising the MaxClients setting

I have couple of questions in my mind

I would like to know which MPM used my apache?. I see both the tags prefork.c and worker.c in my httpd.conf

How do i monitor the MaxClients? any accurate cmds to get it?

woodchuck
06-12-2009, 01:32 PM
woodchuck - I like your post on this error...

Gohnny,

You mistakenly think I know what I am doing. :D The first time I looked at an Apache log file was a couple days ago. All I know about Apache at this point is what I posted here. However the MaxClients variables are found in a file named apache.conf file

woodchuck
06-18-2009, 11:50 AM
This is a followup on actions I performed.

Action: MaxClients increased prefork to 35 (from 30), worker to 15 (from 10) and restarted the container.

Result: Immediately afterwards Desktop/Statistics/Memory useage hovering 250 MB. Web sites seems to load faster. Over the following days the server's memory useage, which has a soft limit of 512MB (burstable to 2GB), starting to warn me of reaching the soft limit. I believe what was happening was the site was loading much faster (double and triple time) and visitors were viewing more content in shorter periods of time. Given the fact that the server was reaching the soft limit around 11 am, it didn't stand a chance of maintaining below the soft limit when the evening time rolled by. My understanding is the server will shut down "if" the burstable memory is not available. I'd rather not have to deal with that so I returned the MaxClients values to the original settings and restarted the container. I have to say that I was spoiled by the faster page serving and now I too have to wait just a little bit more for pages to load.

Future thoughts: Even the techs of the hosting company say I will probably outgrow their service since I have their largest platform. I've only been with them a week! Next time I'm hunting for a server it will probably be either another VPS with a guaranteed 1024 MB memory, or a dedicated server, whatever works better and whoever can provide solid tech "Tier II" support. :thumbsup: