python - Django 应用程序消耗服务器中的内存

标签 python django memory server

我在 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/

相关文章:

python - Django REST Framework 授权 token

Django 从 Popen 进程向 StreamingHttpResponse 发送内容长度

python - 减少从 MongoDB 加载 Pandas 数据帧所用的内存

ios - swift : Does hiding an animating view still affect memory/performance?

Python Pandas Dataframe 数据透视表列和值顺序

Python 随机音频

python - 使用递归在python中获取子字符串

python - 在 django View 中获取抓取的 scrapy 项目

c - 段错误不会发生

python - 模型有多个输出时的ModelCheckpoint监控值