Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have my django application on a VPS server (128mb ram) When i start it with python manage.py runserver, it works perfectly, but if I try to use it over apache/mod_wsgi it causes major slowdown very soon (after I click few random links on my webpage) and it seems to run out of memory. That even happens with "hello world" applications. But it's kinda weird since it runs fine wit manage.py runserver Any ideas?

/var/log/apache2/error.log
-----------------------------
[Wed Feb 10 00:00:40 2010] [error] [client 65.55.37.202] File does not exist: /var/www/robots.txt
[Wed Feb 10 00:01:22 2010] [error] [client 65.55.37.202] File does not exist: /var/www/file
[Wed Feb 10 00:02:32 2010] [warn] child process 2023 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:32 2010] [warn] child process 1961 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:32 2010] [warn] child process 1994 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:32 2010] [warn] child process 1995 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:32 2010] [warn] child process 1996 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:33 2010] [warn] child process 2023 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:33 2010] [warn] child process 1961 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:33 2010] [warn] child process 1994 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:33 2010] [warn] child process 1995 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:33 2010] [warn] child process 1996 still did not exit, sending a SIGTERM
[Wed Feb 10 00:02:34 2010] [notice] caught SIGTERM, shutting down
[Wed Feb 10 00:15:31 2010] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Wed Feb 10 00:15:31 2010] [notice] mod_python: using mutex_directory /tmp 
[Wed Feb 10 00:15:32 2010] [notice] Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch mod_python/3.3.1 Python/2.5.2 mod_wsgi/2.3 configured -- resuming normal operations
[Wed Feb 10 00:17:24 2010] [error] [client 202.152.243.143] File does not exist: /var/www/file, referer: http://www.webmaster-tutorial.com/view/919
[Wed Feb 10 00:19:56 2010] [error] [client 202.152.243.143] File does not exist: /var/www/favicon.ico
[Wed Feb 10 00:20:09 2010] [error] [client 202.152.243.143] File does not exist: /var/www/favicon.ico
[Wed Feb 10 00:23:25 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:23:41 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:23:52 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:24:03 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:24:16 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:24:29 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:24:39 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:24:51 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:25:01 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:25:11 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:25:21 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:25:31 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 10 00:25:41 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
----------------------------------
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Ensure you aren't using embedded mode. Use daemon mode instead. See:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

for an explanation of why embedded mode is bad for constrained memory environments.

BTW, also ditch mod_python and use a more up to date mod_wsgi, specifically mod_wsgi 3.X and set:

WSGIRestrictEmbedded On

in addition to using daemon mode to get even more memory savings.

share|improve this answer
    
thanks, it seems to work I will just leave link that explains how to enable daemon mode if anyone finds this code.google.com/p/modwsgi/wiki/IntegrationWithDjango –  dabrorius Feb 10 '10 at 11:29
    
An alternate link which describes basic daemon mode setup is 'code.google.com/p/modwsgi/wiki/QuickConfigurationGuide';. –  Graham Dumpleton Feb 10 '10 at 22:10

Your Answer

 
discard

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.