Timeout when reading response headers from daemon process. mod_wsgi, python, flask, apache, centos

308 views
Skip to first unread message

ramiro rodriguez

unread,
Mar 29, 2021, 4:07:44 PMMar 29
to mod...@googlegroups.com
Hi Graham and everyone,

I have a problem with my mod_wsgi configuration. Sometimes, I think that when there is a lot of traffic on my website, the page breaks and says "Resource temporarily unavailable..."

Timeout when reading response headers from daemon process

(11)Resource temporarily unavailable: [client 181...] mod_wsgi (pid=4726): Unable to connect to WSGI daemon process 'FlaskApp' on '/run/httpd/wsgi.28794.0.1.sock' after multiple attempts as listener backlog limit was exceeded or the socket does not exist.


The website makes aprox 12 requests every 2 minutes.

This is my httpd.conf file 

<VirtualHost *:443>

        DocumentRoot "/var/www/FlaskApp/FlaskApp"
        ServerName 54.165.200.2000
      
        WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
        WSGIDaemonProcess FlaskApp python-path=/var/www/FlaskApp/FlaskApp/venv/lib/python3.6/site packages processes=6 threads=5  
        WSGIProcessGroup FlaskApp
        <Directory /var/www/FlaskApp/FlaskApp/>
                WSGIProcessGroup FlaskApp             
                WSGIApplicationGroup %{GLOBAL}            
                Order allow,deny
                Allow from all
        </Directory>
        Alias /static /var/www/FlaskApp/FlaskApp/static
        <Directory /var/www/FlaskApp/FlaskApp/static/>
                Order allow,deny
                Allow from all
        </Directory>

What's causing the problem?
Thanks!
 

Graham Dumpleton

unread,
Mar 29, 2021, 4:19:55 PMMar 29
to mod...@googlegroups.com
The most likely cause for this is that something is triggering a graceful restart of Apache. Most likely this could be your system logging system doing a restart of Apache because of the need to rotate log files.

Apache actually has its own way of managing and rotating log files so that there is no need to do a restart of Apache, but Linux systems totally ignore that and do it their own way, which in the default configuration with mod_wsgi can result in this error, since you get stale socket information in Apache child worker process since the socket for the daemon process group gets changed on each restart, yet Apache child worker processes when graceful restart is used can hang around longer if keep alive connections are used for clients.

Seems it is missing from the main docs and only mention in change notes, but you can try setting:

    WSGISocketRotation Off

This will cause it to use the same socket name for daemon process groups across restarts.

Make that change and see if things improve.

Also look at the Apache logs and see if you can confirm if anything is trigger an Apache restart. You may need to have the Apache log level set to info rather than err or warn to see information about restarts.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/CAA6KZoRBLfVbD7bfwiDJbT8FNq5rL8AAA2OmxLyZEkbUd%3D3rVw%40mail.gmail.com.

ramiro rodriguez

unread,
Mar 29, 2021, 5:08:21 PMMar 29
to mod...@googlegroups.com

Graham, thanks for your reply.

I tried to add WSGISocketRotation Off to my httpd.conf but it doesn't work. My browser shows this:
image.png

Is there another way to add that sentence to my configuration?

In my apache log, I don't see any graceful restart of Apache before "Timeout when reading response headers from daemon process..."

Thanks in advance!


Graham Dumpleton

unread,
Mar 29, 2021, 5:17:09 PMMar 29
to mod...@googlegroups.com
What was the error in the Apache error logs?

You could be using a really old mod_wsgi version which doesn't have that option, in which case you should consider upgrading mod_wsgi.

Also, that option must go outside of any VirtualHost, not inside. The error may be because you used it inside and Apache will not start properly.

Graham

On 30 Mar 2021, at 8:08 am, ramiro rodriguez <mercadol...@gmail.com> wrote:

Graham, thanks for your reply.

I tried to add WSGISocketRotation Off to my httpd.conf but it doesn't work. My browser shows this:

ramiro rodriguez

unread,
Mar 29, 2021, 5:55:20 PMMar 29
to mod...@googlegroups.com
Ok, i was adding the sentence inside the VirtualHost.  I set it outside, and apache works. I will try if this solves the problem.

Thanks Graham

Ramiro

Reply all
Reply to author
Forward
0 new messages