"杀"进程和django / gunicorn内存占用

时间:2014-10-19 19:48:15

标签: python django memory gunicorn postgresql-9.3

我在我的日志中看到了一些Killed消息用于我的gunicorn进程,有时当我在django shell上时,它只是获得Killed

经过一些研究后,我发现这可能导致资源不足,特别是记忆力下降。 我正在开发使用512MB的流浪虚拟机,具有以下堆栈:

Nginx
+
Gunicorn with 3 workers
+
3 RQ workers
+
Redis as Cache
+
Redis as DataStore (is not meant to store a lot of data, mainly used to store the queues for the workers)
+ 
PostgreSQL

对于部署,我最初计划使用2台1GB的机器启动。 DataBase(PostgreSQL Server)将在一台机器上,而所有其他机器在另一台机器上。我想知道我是否应该根据我发现的内容改变这个计划。

Machine 1 of 1GB: Nginx, Gunicorn, RQ Workers, Redis Cache, Redis DataStore
Machine 2 of 1GB: PostgreSQL

事实上,当我查看内存消耗时,我发现它更像是枪手,RQ工作人员正在消耗大量内存。每个流程大约45MB,有7个流程(4个Gunicorn + 3个RQ工作者)。

1)django应用程序的内存占用是否正常?

2)这些过程能否发展得更大?

3)另外,任何关于postgres: my_project my_project 10.0.0.51 idle进程的概念是什么?

(venv)mike@vagrant-ubuntu-trusty-64:/var/local/sites/my_project$ ps aux --sort=-rss,-vsz | head -21
USER           PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
my_project   24650  0.2  8.7 161200 44072 ?        S    19:14   0:02 /var/local/sites/my_project/venv/bin/python /projects/my_project/webapp/manage.py rqworker high
my_project   24654  0.2  8.7 161188 44072 ?        S    19:14   0:02 /var/local/sites/my_project/venv/bin/python /projects/my_project/webapp/manage.py rqworker high default low
my_project   24651  0.2  8.7 161184 44068 ?        S    19:14   0:02 /var/local/sites/my_project/venv/bin/python /projects/my_project/webapp/manage.py rqworker high default low
my_project   26144  0.2  8.6 163612 43628 ?        S    19:14   0:01 /var/local/sites/my_project/venv/bin/python /var/local/sites/my_project/venv/bin/gunicorn my_project.wsgi:application --name my_project_app --workers 3 --user=my_project --group=my_project --log-level=info --bind=unix:/tmp/my_project.gunicorn.sock --access-logfile=/projects/my_project-logs/vm_logs/gunicorn-my_project-access.log --log-file=/projects/my_project-logs/vm_logs/gunicorn-my_project.log
my_project   26143  0.2  8.6 163596 43608 ?        S    19:14   0:01 /var/local/sites/my_project/venv/bin/python /var/local/sites/my_project/venv/bin/gunicorn my_project.wsgi:application --name my_project_app --workers 3 --user=my_project --group=my_project --log-level=info --bind=unix:/tmp/my_project.gunicorn.sock --access-logfile=/projects/my_project-logs/vm_logs/gunicorn-my_project-access.log --log-file=/projects/my_project-logs/vm_logs/gunicorn-my_project.log
my_project   26139  0.2  8.6 163592 43608 ?        S    19:14   0:01 /var/local/sites/my_project/venv/bin/python /var/local/sites/my_project/venv/bin/gunicorn my_project.wsgi:application --name my_project_app --workers 3 --user=my_project --group=my_project --log-level=info --bind=unix:/tmp/my_project.gunicorn.sock --access-logfile=/projects/my_project-logs/vm_logs/gunicorn-my_project-access.log --log-file=/projects/my_project-logs/vm_logs/gunicorn-my_project.log
postgres     25660  0.0  3.2 246436 16212 ?        S    19:14   0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
my_project   26102  0.0  2.4  56704 12332 ?        S    19:14   0:00 /var/local/sites/my_project/venv/bin/python /var/local/sites/my_project/venv/bin/gunicorn my_project.wsgi:application --name my_project_app --workers 3 --user=my_project --group=my_project --log-level=info --bind=unix:/tmp/my_project.gunicorn.sock --access-logfile=/projects/my_project-logs/vm_logs/gunicorn-my_project-access.log --log-file=/projects/my_project-logs/vm_logs/gunicorn-my_project.log
root         24615  0.0  2.3  56624 11936 ?        Ss   19:14   0:00 /usr/bin/python /usr/local/bin/supervisord -c /etc/supervisord.conf --nodaemon
postgres     25679  0.0  1.2 247668  6268 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55189) idle
postgres     25674  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55187) idle
postgres     25678  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55188) idle
postgres     25683  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55190) idle
postgres     26547  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55191) idle
postgres     26548  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55192) idle
postgres     26549  0.0  1.2 247668  6264 ?        Ss   19:14   0:00 postgres: my_project my_project 10.0.0.51(55193) idle
my_project   26652  0.0  0.8  21844  4284 pts/0    Ss   19:15   0:00 -bash
root         26603  0.0  0.8 107696  4236 ?        Ss   19:15   0:00 sshd: my_project [priv]
postgres     25662  0.0  0.6 246572  3200 ?        Ss   19:14   0:00 postgres: checkpointer process

0 个答案:

没有答案