Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PHP/MySQL web application that gets about 600,000 hits per month. It has been running well for the last few months, but more recently the server is OOMing and crashing. The times between the memory crashes was more rare, but now it has crashed twice in the last two days. When it is running it runs really fast, I just can't keep having the site go down so often.

Does anyone have any ideas on how to fix my problem or have any recommendations on another web host that might fix this problem.

My server setup: Unmanaged VPS (512MB of dedicated memory) It runs CentOS, Apache2, and PHP 5.2. I am only running web applications using PHP and MySQL. My popular application is using cakePHP. I host other sites here, but they do not get many hits. I need to have automated backups.

share|improve this question
up vote 0 down vote accepted

It seems that you're getting unpredictable spikes and apache's MaxClients directive is greater than what your server can handle.

If you're using mpm_prefork, every single request will be handled by a separate apache child and each child consumes memory.

From the apache docs: "This MPM is very self-regulating, so it is rarely necessary to adjust its configuration directives. Most important is that MaxClients be big enough to handle as many simultaneous requests as you expect to receive, but small enough to assure that there is enough physical RAM for all processes." (

Check the memory size consumed by each apache process and try adjusting your MaxClients, MinSpareThreads and MaxSpareThreads directives to fit the available memory.

Additionally, you can set your MaxRequestsPerChild directive lower, so that you avoid getting OOM errors in case your application is causing a memory leakage. Don't set it too low. If you do so, you'll run into a CPU bottleneck, since children will be frequently killed and created.

Moreover, a big KeepAliveTimeout can keep your apache children unnecessarily busy with a request that has already been fulfilled. I'd definitely check that in your apache configuration. For more information on apache keep alive directives, read

Finally, consider buying more RAM.

Summarizing, I believe you need an Apache tuning/tweak. For now, forget about blaming the web host company...

share|improve this answer
Thanks for the response. I will definitely look into the Apache settings, and look into getting more RAM. I wasn't trying to blame the host, but thinking that someone might have a good managed VPS option out there, since I don't know very much about these types of problems. – cyphun Mar 14 '12 at 7:30
Before looking into getting more RAM, you should definitely check your apache settings. When you have them adjusted correctly, you'll most likely stop the OOM errors. I appreciate your acknowledgment, @cyphun. However, in serverfault, when you think an answer is useful and helps you, we thank people voting their answers up :) – Luis Fernando Alen Mar 14 '12 at 15:20
Not enough rep to vote up :( – cyphun Mar 14 '12 at 15:39
If I set this limit to something reasonable for my current server, what happens when Apache runs out of connections and someone tries to connect to the website? – cyphun Mar 15 '12 at 0:11
When the limit is reached, the kernel will start queuing the next requests and they will wait for an available apache child to answer them. I think it's been pretty well explained here: – Luis Fernando Alen Mar 15 '12 at 2:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.