我在 Ubuntu 16.04 上使用 Postgres、Nginx 和 Gunicorn 在 Digital Ocean(512MB 内存)中安装了 django 应用程序。在运行应用程序时,它会消耗更多内存。如果我浏览页面,它也会在使用 top 命令检查时消耗内存。会出现什么问题,可能的原因是什么。
unicorn
[Unit]
Description=veeyar daemon
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/webapps/myproject/
ExecStart=/home/webapps/myproject/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/webapps/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
Nginx
server {
listen 9090;
location = /favicon.ico { access_log off; log_not_found off; }
location ^/static/ {
root /home/webapps/myproject/staticfiles;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/webapps/myproject/myproject.sock;
}
}
而且在 settings.py 中我设置了 DEBUG=False。
我尝试通过谷歌搜索它,但我无法正确理解。为什么会这样,我是否遗漏了什么。你们能帮我解决这个问题吗?这对我来说会非常充实。提前致谢。
最佳答案
我会推荐你this关于 Django 性能的帖子,Django 中巨大内存的主要原因之一是因为您使用的是列表而不是迭代器。
问候。
关于python - Django 应用程序消耗服务器中的内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45094799/