django - Django Apache 和 Elastic Beanstalk 的 API 响应时间很慢
问题描述
我在 django 中有一个 POST API,并且我已经为应用程序安装了 New Relic APM。django 处理请求所需的时间约为 250 毫秒,但响应时间(从邮递员测量)约为 2.5 秒。
我的架构设置在 AWS Elastic Beanstalk 上。
负载均衡器(使用 SSL)用作 Web 界面
一个 Linux 实例通过 WSGI 与 Django 应用程序一起运行 Apache
连续请求的响应时间从 2.5 秒到 600 毫秒不等。如何识别问题并将响应时间缩短到 500 毫秒以下
这是我用于 http.d 的 wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On
<VirtualHost *:80>
Alias /static/ /opt/python/current/app/static/
<Directory /opt/python/current/app/static/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /opt/python/current/app/test_proj/wsgi.py
WSGIPassAuthorization On
WSGIPassAuthorization On
WSGIPassAuthorization On
<Directory /opt/python/current/app/>
Require all granted
</Directory>
WSGIDaemonProcess wsgi processes=1 threads=15 display-name=%{GROUP} \
python-home=/opt/python/run/venv/ \
python-path=/opt/python/current/app:/opt/python/run/venv/lib64/python3.6/site-packages:/opt/python/run/venv/lib/python3.6/site-packages user=wsgi group=wsgi \
home=/opt/python/current/app
WSGIProcessGroup wsgi
</VirtualHost>
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
解决方案
推荐阅读
- postgresql - 我可以使用内部联接改进此查询吗?
- c++ - 查找所有输入字符串中常见字符的数量 - C++14
- python - 为什么管道中的过采样会爆炸模型系数的数量?
- android - 在 android studio 错误中构建本机库 - ndk-build.cmd 以非零退出值完成 2 在 Windows 中执行问题
- svn - 在一行中获取 SVN 签入日期和注释
- intellij-idea - 生成 android build 显示错误
- django - 1小时后如何从数据库中删除数据?
- nunit - 是否可以一次将 Nunit 和 SpecRun 作为 UnitTestProviders。
- java - 部署到 tomcat 后,Spring Boot 应用程序未从数据库接收数据
- jenkins - 即使文件存在,Jenkins 管道“内容替换”插件也会出现“找不到文件”错误