Apache 和 mod_wsgi 的几个进程
Several processes with Apache and mod_wsgi
我有一个与 Apache 和 mod_wsgi 一起使用的 Python 网络应用程序(使用 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>
不要使用嵌入模式:
然后继续完全禁用嵌入式模式,这样 Python 解释器甚至不会在 Apache 子进程中初始化。
我有一个与 Apache 和 mod_wsgi 一起使用的 Python 网络应用程序(使用 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>
不要使用嵌入模式:
然后继续完全禁用嵌入式模式,这样 Python 解释器甚至不会在 Apache 子进程中初始化。