【问题标题】:Several processes with Apache and mod_wsgiApache 和 mod_wsgi 的几个进程
【发布时间】:2017-10-26 21:16:09
【问题描述】:

我有一个与 Apache 和 mod_wsgi 一起使用的 Python webapp(使用 Flask)。现在,只要我启动 Apache,我就会看到启动了 4 个 Apache 进程(参见下面的 htop 屏幕截图)。

现在,根据对应用程序的 POST 请求,我看到其中一个进程正在运行,而其他进程则什么也不做。接下来的几个 POST 请求(介于 2 到 5 个请求之间)仍然发送到第一个进程,但之后使用了第二个进程,这让我遇到了内存问题。你能告诉我如何防止这种情况发生吗?这是我的 Apache 配置文件:

<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerName mydomain.com
    ServerAlias www.mydomain.com
    ServerAdmin admin@mydomain.com
    DocumentRoot /var/www/html


    WSGIScriptAlias /myapp /var/www/wsgi-scripts/myapp.wsgi


    ErrorLog ${APACHE_LOG_DIR}/myapp.error.log
    CustomLog ${APACHE_LOG_DIR}/myapp.access.log combined

    # I tried with commenting and un-commenting this, same result
    <Directory /var/www/wsgi-scripts>
        Order allow,deny
        Allow from all
    </Directory>

    RewriteEngine on
    tps://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

【问题讨论】:

    标签: apache flask mod-wsgi wsgi


    【解决方案1】:

    不要使用嵌入模式:

    然后继续完全禁用嵌入式模式,这样 Python 解释器甚至不会在 Apache 子工作进程中初始化。

    【讨论】:

      猜你喜欢
      • 2014-03-02
      • 1970-01-01
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 2011-09-24
      • 2013-02-04
      • 2019-05-19
      相关资源
      最近更新 更多