Hi,
I use uwsgi via mod_proxy from an outdated Apache 2.2.10 (prefork
MPM) for a couple of django applications (controlled by an emperor). The
server load is low, memory is plenty. Django is 1.1.4
Sometimes, though, it happened that one of the uwsgi instances was
completely blocked. From the perspective of the browser, requests were
accepted but left hanging without response. This would coincide with
multiple strange requests which quickly closed the connecition and
obviously only tried to spam the logs with the referer.
I tried heartbeats, this helped to cut downtime to a short period.
I used tcpdump to inspect the traffic between Apache and uwsgi, and it
showed that many connections were half-closed by uwsgi, but left open
from apache, then finally resetted after 20 minutes. Apache always sent
"Connection: Keep-Alive" in the http headers, uwsgi did not respond with
"Connection: Closed", but half-closed the connection.
I finally switched off persistent connections from Apache to the proxy,
after that everything has been fine and I have not experienced the
failures again.
Is this a bug in the django app? A bug in uwsgi? Am I misunderstanding
something? Or is it really required to switch off persistent connections
like I did?
My uwsgi config:
-----------------------------------------
[uwsgi]
# set instance
INSTANCE=instancename
NR=09
HOTCLUB=/srv/hotclub/django
VPY=%(HOTCLUB)/webapp
# settings
env=DJANGO_SETTINGS_MODULE=site.settings
uid=django
include=%d/defaults.ini
processes=2
reload-mercy=8
listen=16
harakiri=60
harakiri-verbose
threads=4
evil-reload-on-rss=150
--------------------------------------
default.ini is:
--------------------------------------
[uwsgi]
strict
# logging
# offload-log
req-logger = file:/var/log/uwsgi/%(INSTANCE).log
logger = file:/var/log/uwsgi/%(INSTANCE).log
logger = file:/var/log/uwsgi/%(INSTANCE).err
logformat = %(ltime) %(host) %(addr) (%(status)) %(msecs) ms %(method) %(proto)
%(uri) [%(pid)/%(wid)] {rss %(rssM) MB} {cl %(cl)} {hsize %(hsize)} {rsize %(r
size)} {cl %(cl)} {referer %(referer)}
log-x-forwarded-for
memory-report
# log-date
# reloading, limits
touch-reload=%d/reload/%(INSTANCE)
touch-reload=%(VPY)/reload
touch-reload=%d/reload/all
reload-on-rss=100
# process owner, caps
# cap=net_bind_service
gid=hotclub
# process control
master
processes=2
threads=4
http-processes=2
offload-threads=2
thunder-lock
procname=uwsgi-%(NR)-%(INSTANCE)
post-buffering=100000
enable-threads
# reload-on-exception
heartbeat=10
reload-mercy=60
# wsgi setup
module=django.core.handlers.wsgi:WSGIHandler()
home = %(VPY)
chdir=%(HOTCLUB)
# sockets
http-socket=127.0.0.2:80%(NR)
stats=127.0.0.2:90%(NR)
--------------------------------------
previous Apache config:
--------------------------------------
ProxyPreserveHost On
ProxyReceiveBufferSize 32768
ProxyPassMatch ^/(...static files ...) !
ProxyPass / http://127.0.0.2:8009/ connectiontimeout=5 retry=10
--------------------------------------
current Apache config:
--------------------------------------
ProxyPreserveHost On
ProxyReceiveBufferSize 32768
ProxyPassMatch ^/(...static files ...) !
ProxyPass / http://127.0.0.2:8009/ connectiontimeout=5 retry=10 disablereuse=on
keepalive=off
SetEnv proxy-nokeepalive 1
--------------------------------------
Kind regards
Michael Radziej
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi