Evgeny Turnaev | 1 Sep 10:02 2011
Picon

Persistent connections

It is unclear for me:
 does uWSGI able to maintain persistent connections?
 ("Connection: keep-alive")
 pep 0333 says applications must not send any hop-by-hop headers but it is up to
 server/gateway implementation - to be able to do keepalive connections.

--

-- 
--------------------------------------------
Турнаев Евгений Викторович
+7 906 875 09 43
--------------------------------------------
_______________________________________________
uWSGI mailing list
uWSGI <at> lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Roberto De Ioris | 1 Sep 11:00 2011
Picon

Re: Persistent connections


Il giorno 01/set/2011, alle ore 10:02, Evgeny Turnaev ha scritto:

> It is unclear for me:
> does uWSGI able to maintain persistent connections?
> ("Connection: keep-alive")
> pep 0333 says applications must not send any hop-by-hop headers but it is up to
> server/gateway implementation - to be able to do keepalive connections.
> 

AFAIK there are no web server (of the 4 major) supporting keepalive for proxied apps.

Theoretically uWSGI itself already supports this as this is the only way to work with mongrel2,
so if you care about connection cost you could try using mongrel2.

An interesting feature/challenge would be implementing keep-alive in the uWSGI http router/server. 

--
Roberto De Ioris
http://unbit.it
JID: roberto@...
Roberto De Ioris | 1 Sep 11:40 2011
Picon

[ANNOUNCE] uWSGI 0.9.9.1

An ultra-tiny bigfix release:

- fixed a bug with dynamic virtualenv
- fixed build as shared library in osx

The first bug shows only on the first dynamic app loaded (bug #41)

The second one retuns symbols error when compiling uWSGI as a shared library under osx.

If you do not use them you can avoid the upgrade.

--
Roberto De Ioris
http://unbit.it
JID: roberto@...
Evgeny Turnaev | 1 Sep 14:41 2011
Picon

Re: Persistent connections

First of all: Thank you very much for writing such a good server.
uWSGI wined my personal benchmark against fapws and gevent and also
list of uWSGI feature is outstanding. :)
2011/9/1 Roberto De Ioris <roberto <at> unbit.it>:
>
> Il giorno 01/set/2011, alle ore 10:02, Evgeny Turnaev ha scritto:
>
>> It is unclear for me:
>> does uWSGI able to maintain persistent connections?
>> ("Connection: keep-alive")
>> pep 0333 says applications must not send any hop-by-hop headers but it is up to
>> server/gateway implementation - to be able to do keepalive connections.
>>
>
> AFAIK there are no web server (of the 4 major) supporting keepalive for proxied apps.

Well i am using nginx 1.1.1 patched with this patch
http://mailman.nginx.org/pipermail/nginx-devel/2011-July/001057.html
(upstream keepalive but mail list states only memcached, fastcgi and
http supported)
and this patch
http://forum.nginx.org/read.php?29,213388
(to enable unbuffered uwsgi_pass with nginx)

it compiles perfectly and working..
except nginx mail list said to me that "uwsgi protocol" (maybe he
meant nginx uwsgi_module) does not support keepalive connections.

i am testing this setup with simple wsgi app that yields some strings
in a certain time interval and then
(Continue reading)

Roberto De Ioris | 1 Sep 14:52 2011
Picon

Re: Persistent connections


Il giorno 01/set/2011, alle ore 14:41, Evgeny Turnaev ha scritto:

> 
> it compiles perfectly and working..
> except nginx mail list said to me that "uwsgi protocol" (maybe he
> meant nginx uwsgi_module) does not support keepalive connections.

by default the uwsgi protocol can be streamed everywhere and in every way you want.
The main purpose for it containing the size in each packet is to allows persistent connection (even if not used).

the uwsgi_module in nginx (by default) does not support keepalive

> 
> i am testing this setup with simple wsgi app that yields some strings
> in a certain time interval and then
> returns.
> for every yield nginx in unbuffered mode produces http 1.1 chunk which
> is exactly what i want.

good, i hope igor will push the buffering/unbuffering patch soon

> i am just curious: does uWSGI server able to maintain persistent connection?

yes it is able but currently only with the zeromq handler, writing a persistent uwsgi handler (in
proto/uwsgi.c) it is only a matter
of not closing the connection at the end. As no one is using it, i never implemented it.

I can give it a try adding a 'puwsgi' protocol handler. Take in account that async mode with persistent
connections is broken, so you have to relay
(Continue reading)

Evgeny Turnaev | 1 Sep 15:35 2011
Picon

Re: Persistent connections

2011/9/1 Roberto De Ioris <roberto <at> unbit.it>:
>
> Il giorno 01/set/2011, alle ore 14:41, Evgeny Turnaev ha scritto:
>
>>
>> it compiles perfectly and working..
>> except nginx mail list said to me that "uwsgi protocol" (maybe he
>> meant nginx uwsgi_module) does not support keepalive connections.
>
>
> by default the uwsgi protocol can be streamed everywhere and in every way you want.
> The main purpose for it containing the size in each packet is to allows persistent connection (even if not used).
>
> the uwsgi_module in nginx (by default) does not support keepalive
>
>>
>> i am testing this setup with simple wsgi app that yields some strings
>> in a certain time interval and then
>> returns.
>> for every yield nginx in unbuffered mode produces http 1.1 chunk which
>> is exactly what i want.
>
> good, i hope igor will push the buffering/unbuffering patch soon
>
>> i am just curious: does uWSGI server able to maintain persistent connection?
>
> yes it is able but currently only with the zeromq handler, writing a persistent uwsgi handler (in
proto/uwsgi.c) it is only a matter
> of not closing the connection at the end. As no one is using it, i never implemented it.
>
(Continue reading)

Andy | 2 Sep 06:54 2011
Picon

Re: Persistent connections





>I can give it a try adding a 'puwsgi' protocol handler. Take in account that async mode with persistent connections is broken, so you have to relay
>on threads and processes.

Can you clarify what you mean by "async mode with persistent connections is broken"?

I understand that right now uWSGI does not support persistent connection but that feature can be added, right? Are you also saying that even if you add persistent connection to uWSGI it still won't work with async/gevent? If so, is there any fundamental reason why async doesn't work with persistent connection?



_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Roberto De Ioris | 2 Sep 07:12 2011
Picon

Re: Persistent connections


>
>
>
>
> ________________________________
>
>
>>I can give it a try adding a 'puwsgi' protocol handler. Take in account
>> that async mode with persistent connections is broken, so you have to
>> relay
>>on threads and processes.
>
>
> Can you clarify what you mean by "async mode with persistent connections
> is broken"?
>
> I understand that right now uWSGI does not support persistent connection
> but that feature can be added, right?

right

Are you also saying that even if you
> add persistent connection to uWSGI it still won't work with async/gevent?
> If so, is there any fundamental reason why async doesn't work with
> persistent connection?

because the current async.c code stop to process events after it receives
a full uwsgi/fastcgi/http message. All the following bytes will be
directly read by the application itself (via
wsgi.input/rack.input/psgi.input and so on).

It should be updated to re-add the socket to the event queue. Could be
easy, but it requires a lot of testing infrastructure as the async mode is
the base for 6 plugins (gevent included)

--

-- 
Roberto De Ioris
http://unbit.it
Andy | 2 Sep 08:18 2011
Picon

Re: Persistent connections


>because the current async.c code stop to process events after it receives
>a full uwsgi/fastcgi/http message. All the following bytes will be
>directly read by the application itself (via
>wsgi.input/rack.input/psgi.input and so on).

>It should be updated to re-add the socket to the event queue. Could be
>easy, but it requires a lot of testing infrastructure as the async mode is
>the base for 6 plugins (gevent included)

Ah I see... so any plan of implementing that? It'd be cool :)
_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Lloyd A. Duke | 2 Sep 18:39 2011

File upload client disconnect error

While submitting a multipart form with a file upload without fail I 
always receive a client disconnected error while reading the file.
This works for me using the paster server but when I migrate to uWSGI I 
always receive this error. I am really kind of stumped.

  File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebError-0.10.3-py2.7.egg/weberror/evalexception.py", 
line 235, in __call__
     return self.respond(environ, start_response)
   File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebError-0.10.3-py2.7.egg/weberror/evalexception.py", 
line 475, in respond
     if self.xmlhttp_key in req.params:
   File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebOb-1.1rc1-py2.7.egg/webob/request.py", 
line 648, in params
     params = NestedMultiDict(self._str_GET, self._str_POST)
   File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebOb-1.1rc1-py2.7.egg/webob/request.py", 
line 558, in _str_POST
     keep_blank_values=True)
   File "/usr/lib/python2.7/cgi.py", line 513, in __init__
     self.read_multi(environ, keep_blank_values, strict_parsing)
   File "/usr/lib/python2.7/cgi.py", line 638, in read_multi
     environ, keep_blank_values, strict_parsing)
   File "/usr/lib/python2.7/cgi.py", line 515, in __init__
     self.read_single()
   File "/usr/lib/python2.7/cgi.py", line 654, in read_single
     self.read_lines()
   File "/usr/lib/python2.7/cgi.py", line 677, in read_lines
     self.read_lines_to_outerboundary()
   File "/usr/lib/python2.7/cgi.py", line 705, in 
read_lines_to_outerboundary
     line = self.fp.readline(1<<16)
   File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebOb-1.1rc1-py2.7.egg/webob/request.py", 
line 1292, in readline
     self._check_disconnect()
   File

"/home/lloyd/dev/test_site/site/lib/python2.7/site-packages/WebOb-1.1rc1-py2.7.egg/webob/request.py", 
line 1311, in _check_disconnect
     + "(%d more bytes were expected)" % self.remaining

using uwsgi 0.9.9.1
nginx 1.0

uwsgi.xml
<uwsgi>
<!-- changeing this from 1 to 12 for the dev. this SHOULD REALLY change 
for prod -->
<processes>1</processes>
<master/>
<socket>/home/lloyd/dev/test_site/site/sock/uwsgi.sock</socket>
<daemonize>/home/lloyd/dev/test_site/site/logs/uwsgi.log</daemonize>
<chmod>666</chmod>
<home>/home/lloyd/dev/test_site/site</home>
<wsgi-file>/home/lloyd/dev/test_site/site/app/app.wsgi</wsgi-file>
<harakiri>180</harakiri>
<harakiri-verbose/>
<!--
         enabling thread support to allow for the long running call to 
create
         test users to stay under the 180 second limit.
         not really using them ... perhaps turn this off.
     -->
<enable-threads/>
</uwsgi>

PS
uwsgi    16868     1  0  80   0 - 33569 ep_pol 11:52 ?        00:00:00 
/home/lloyd/dev/test_site/site/bin/uwsgi -x 
/home/lloyd/dev/test_site/site/etc/uwsgi.xml

Gmane