Django Apache和Elastic Beanstalk的API响应时间较慢

Django Apache和Elastic Beanstalk的API响应时间较慢,django,apache,optimization,amazon-elastic-beanstalk,mod-wsgi,Django,Apache,Optimization,Amazon Elastic Beanstalk,Mod Wsgi,我在django中有一个PostAPI,我已经为应用程序安装了New Relic APM。django处理请求的时间约为250ms,但响应时间(从邮递员处测量)约为2.5秒 我的架构是建立在AWS弹性豆茎上的 使用负载平衡器(带有SSL)作为web界面 一个linux实例通过WSGI运行Apache和Django应用程序 连续请求的响应时间从2.5秒到600毫秒不等。如何识别问题并将响应时间缩短到500毫秒以下 这是我的http.d的wsgi.conf LoadModule wsgi_modul

我在django中有一个PostAPI,我已经为应用程序安装了New Relic APM。django处理请求的时间约为250ms,但响应时间(从邮递员处测量)约为2.5秒

我的架构是建立在AWS弹性豆茎上的

  • 使用负载平衡器(带有SSL)作为web界面

  • 一个linux实例通过WSGI运行Apache和Django应用程序

  • 连续请求的响应时间从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
    
    LoadModule wsgi\u module modules/mod\u wsgi.so
    WSGIPythonHome/opt/python/run/baselinenv
    WSGISocketPrefix运行/wsgi
    WSGirestricton嵌入式
    别名/static//opt/python/current/app/static/
    命令允许,拒绝
    通融
    WSGIScriptAlias//opt/python/current/app/test\u proj/wsgi.py
    WSGIPassAuthorization On
    WSGIPassAuthorization On
    WSGIPassAuthorization On
    要求所有授权
    WSGIDaemonProcess wsgi PROCESS=1线程=15显示名称=%{GROUP}\
    python home=/opt/python/run/venv/\
    python路径=/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
    日志格式“%h(%{X-Forwarded-For}i)%l%u%t\%r\“%>s%b\“%{Referer}i\”\“%{User-Agent}i\”组合
    


    即使不进行处理,也需要那么多时间吗?您是否发送回了大量数据?首先看看您是如何在Apache中配置mod_wsgi的,这会很有用。@GrahamDumpleton AWS会自动为Apache配置wsgi。我在这里添加了配置文件。您是否尝试过使用任何APM产品(如New Relic或Datadog)来了解您的应用程序代码实际在做什么?@GrahamDumpleton我附上了New Relics数据,其中应用程序的平均响应时间为250ms-300ms,但第一个请求的端到端时间约为1.5-2秒,然后它就会停止至500ms-700ms