django mod_wsgi problema de memória

2

Eu tenho meu aplicativo django em um servidor VPS (128mb de RAM) Quando eu inicio com o python manage.py runserver, ele funciona perfeitamente, mas se eu tentar usá-lo no apache / mod_wsgi ele causará lentidão maior muito em breve (depois que eu clico em alguns links aleatórios na minha página) e parece ficar sem memória. Isso acontece mesmo com os aplicativos "hello world". Mas é meio estranho, uma vez que funciona bem wit manage.py runserver Alguma idéia?

/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
----------------------------------
    
por dabrorius 10.02.2010 / 01:45

1 resposta

3

Verifique se você não está usando o modo incorporado. Use o modo daemon em seu lugar. Veja:

link

para uma explicação de porque o modo incorporado é ruim para ambientes com memória restrita.

BTW, também abandona o mod_python e usa um mod_wsgi mais atualizado, especificamente mod_wsgi 3.X e set:

WSGIRestrictEmbedded On

além de usar o modo daemon para obter ainda mais economia de memória.

    
por 10.02.2010 / 02:38