Joko
Joko

Reputation: 176

Several processes with Apache and mod_wsgi

I have a Python webapp (using Flask) that I serve with Apache and mod_wsgi. Now, as soon as I start Apache, I see there are 4 Apache processes that are started (see htop screenshot below). enter image description here

Now, upon a POST request to the app, I see one of these processes working, with the others doing nothing. The next few POST requests (something between 2 and 5 requests) are still sent to that first process, but after that a second process is used, which lets me run into memory issues. Can you tell me how I can prevent this? This is my Apache conf:

<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>

Upvotes: 0

Views: 218

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

Don't use embedded mode:

And then go on to disabling embedded mode altogether so Python interpreters are not even initialised in Apache child worker processes.

Upvotes: 1

Related Questions