One of my Linux web servers recently ran out of memory, hung itself in an OOM kill frenzy, and had to be rebooted. This is a 512 MB VPS, but it has been running without problems since it was set up months ago. How can I prevent this from happening again?

I have not been able to find out from the logs which process was the cause. The processes killed were mysqld followed by apache2. Based on what's running on the box, I think it's likely that something went wrong in one of the Django applications (running under apache and mod_wsgi). Would limit the stack size (with the stack-size option to wsgi) help? Is is possible to limit wsgi or python or apache's memory usage in general? (The answers to this question say no.)


Don't run your WSGI application in embedded mode with prefork MPM if you are, use daemon mode instead so number of processes limited. Read:


In version 4.0 of mod_wsgi, so long as you are using daemon mode, you can restrict memory of individual processes if operating system supports it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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