WSGI: (11) Couldn't create worker thread

Viewed 267

I set up an apache2 server running 2 different django projects as virtual hosts using their own subdomain. Both hosts got their own demon WSGI process. However, when I start the apache2 server only one of those 2 projects run properly. Trying to open the index page of project 2 leads to an endless loading try by the browser.

So I checked the error.log of apache2 and saw, that it was full of

[wsgi:alert] [pid xxxx:tid xxxxxxx] (11)Resource temporarily unavailable: mod_wsgi (pid=xxxx): Couldn't create worker thread x in project2 process project2

It logs this message every 5 sec. or whenever a request for project 2 comes in. That explains, why there is this infinite waiting loop in the browser, but I don't get, why no thread could be spawned. I already looked around the web for a possible solution, but did not find anything helpfull. Most of the findings were either different problems, had no solution or had a solution that was out of date or used files I can't find on my system.

Using top I did not find any unexpectedly high usage of CPU or Memory that could explain, why no thread was spawned. I already tried to increase the Thread limit, Min/MaxSpareThreads and StartServers in the mpm_event.conf, but didn't notice any improvement of the situation.

I suspect that there is some kind of limit defined anywhere inside the system, either apache2 itself or in ubuntu, but I just can't find it. Below are my potentially relevant config files:

apache2.conf

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

mpm_event.conf

<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          128
    ThreadsPerChild      25
    MaxRequestWorkers     150
    MaxConnectionsPerChild   0
</IfModule>

project1.conf

<VirtualHost *:80>
    ServerName p1.domain.de

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/

    Alias /static/ /var/www/project1/static/

    <Directory /var/www/project1/static>
        Require all granted
    </Directory>

    <Directory /var/www/project1/project1>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIScriptAlias / /var/www/project1/project1/wsgi.py

    WSGIDaemonProcess project1 python-path=/var/www/project1 python-home=/var/www/p1_env
    WSGIProcessGroup project1

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

</VirtualHost>

project2.conf

<VirtualHost *:80>
    ServerName domain.de
    ServerAlias www.domain.de

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/

    Alias /static/ /var/www/project2/static/

    <Directory /var/www/project2/static>
        Require all granted
    </Directory>

    <Directory /var/www/project2/project2>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIScriptAlias / /var/www/project2/project2/wsgi.py

    WSGIDaemonProcess project2 python-path=/var/www/project2 python-home=/var/www/p2_env
    WSGIProcessGroup project2

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

</VirtualHost>
0 Answers
Related