I've recently switched some stable django apps from nginx+apache/modwsgi to 
nginx+uwsgi.

Everything looks great. Memory usage is way down. Concurrency seems better too.

However. On one app in particular, after about 30-60 minutes traffic it starts 
throwing these --

writev(): Broken pipe [plugins/python/wsgi_headers.c line 171]
write(): Broken pipe [plugins/python/wsgi_subhandler.c line 189]

Then these --

*** HARAKIRI ON WORKER 1 (pid: 2578) ***
HARAKIRI: --- uWSGI worker 1 (pid: 2578) WAS managing request /inject/ since 
Tue Mar  8 17:03:21 2011 ---
DAMN ! process 2578 died :( trying respawn ...
Respawned uWSGI worker (new pid: 9765)

Then it starts hanging connections- avg response time increases to around 15 
seconds (from ~1s).

I'm using emperor mode; with 4 'process' workers, master 'on', and logging 
disabled (errors only) for this app.

Any ideas? Here's what it spits out when I restart after it starts hanging --

received message 1 from emperor
...gracefully killing workers...
Gracefully killing worker 1 (pid: 17726)...
Gracefully killing worker 3 (pid: 17728)...
Gracefully killing worker 2 (pid: 32471)...
Gracefully killing worker 4 (pid: 17729)...
binary reloading uWSGI...
closing all non-uwsgi socket fds > 2 (_SC_OPEN_MAX = 1024)...
found fd 4
running /usr/local/sbin/uwsgi
*** has_emperor mode detected (fd: 13) ***
[uWSGI] parsing config file site.xml
open(): Permission denied [utils.c line 158]
*** Starting uWSGI 0.9.7-dev (32bit) on [Mon Mar  7 23:46:07 2011] ***
compiled with version: 4.4.3 on 07 March 2011 21:36:51
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 1001
setuid() to 1001
your memory page size is 4096 bytes
 *** WARNING: you have enabled harakiri without post buffering. Slow upload 
could be rejected on post-unbuffered webservers *** 
uwsgi socket 0 bound to UNIX address /var/run/uwsgi/site.sock fd 4
Python version: 2.6.5 (r265:79063, Apr 16 2010, 13:28:26)  [GCC 4.4.3]
Python main interpreter initialized at 0x9d99dd8
your server socket listen backlog is limited to 100 connections
*** Operational MODE: preforking ***
WSGI application 0 (SCRIPT_NAME=) ready on interpreter 0x9d99dd8 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2577)
spawned uWSGI worker 1 (pid: 2578, cores: 1)
spawned uWSGI worker 2 (pid: 2579, cores: 1)
spawned uWSGI worker 3 (pid: 2580, cores: 1)
spawned uWSGI worker 4 (pid: 2581, cores: 1)

Not sure why it says "permission denied"- it creates the log and socket fine; 
or why "multiple interpreter mode", when I only have one "application" in my 
wsgi-file. I'm pretty sure nginx has post buffering enable so I've ignored the 
other warning.

I'm starting emperor with this --

/usr/local/sbin/uwsgi --emperor /etc/uwsgi/emperor.d/ 
--logto=/var/log/uwsgi/uwsgi.log

And the site in questions' xml file --

<uwsgi>
<uid>1001</uid>
<gid>1001</gid>
<socket>/var/run/uwsgi/site.sock</socket>
<chmod-socket>666</chmod-socket>
<wsgi-file>/home/site/apache/run.wsgi</wsgi-file>
<logto>/var/log/uwsgi/site.log</logto>
<disable-logging /> <!-- errors only -->
<master />
<reaper />
<harakiri>30</harakiri>
<processes>4</processes>
<!--<threads>16</threads>-->
</uwsgi>

And the wsgi file --

#!/usr/bin/python
"""
Simple handler to run django via apache mod wsgi.

Note the line at the top may need to be changed to point to the desired 
version of Python if there are multiple versions installed.
"""

PROJECT_NAME = 'project'  # Required

import os, sys
curdir = os.path.dirname(os.path.abspath(os.path.join(__file__, '..')))
sys.path = [ curdir, '%s/%s' % (curdir, PROJECT_NAME), '%s/lib' % curdir ] + 
sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % PROJECT_NAME
os.environ['PYTHON_EGG_CACHE'] = '%s/.python-eggs/' % curdir

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()




Simon Litchfield
S29.com.au

M  +61-416-027-826
F  +61-2-8569-2377

_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to