Option to disable buffering in uwsgi module

Peter Smit peter at smitmail.eu
Fri Sep 23 06:24:29 UTC 2011


>
> On Thu, Aug 04, 2011 at 01:32:14PM +0300, Peter Smit wrote:
> > (This is my first message to this list, please let me know if I'm
> > doing something wrong!)
> >
> > In developing a comet style application in a uwsgi/nginx setup I
> > noticed that nginx always buffers the response when uwsgi_pass is
> > used.
> >
> > I'm not sure or there is any particular reason why this is done,
> > except for the fact that the uwsgi code is originally based on the
> > fastcgi module where indeed buffering is unavoidable. I think however
> > that it makes sense to give the option of disabling buffering with
> > uwsgi.
> >
> > I actually already went ahead and wrote a patch that does exactly
> > this. It introduces a uwsgi_buffering flag and now adheres to the
> > "X-Accel-Buffering" header. I have only limited capabilities to test
> > this patch, but for me it does exactly that, disabling the buffer.
> >
> > Could some of you review this patch and if it is ok, could it be
> > introduced in nginx?
> >
> > I made the patch on the 1.1.0 source. I attached it and included it
> > inline below this message. Let me know if I should give it in a
> > different format.
>
> Thank you for idea, it seems unbuffered proxying should work for uwsgi
> as well as for scgi, since they both use simple protocol, that is, no
> protocol at all :) for body.
>
>
>
How does the process go further? I noticed that the patch is not included
yet. Are you waiting for someone to step up to make a patch also for scgi,
or are there other reasons for not applying the patch yet?

Regards,

Peter Smit


> --
> Igor Sysoev
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



--- nginx-1.1.0/src/http/modules/ngx_http_uwsgi_module.c        2011-07-29
18:33:03.000000000 +0300
+++ nginx-1.1.0-uwsgi_buffering/src/http/modules/ngx_http_uwsgi_module.c
   2011-08-04
13:16:54.381528459 +0300
@@ -123,6 +123,13 @@
      offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),
      NULL },

+    { ngx_string("uwsgi_buffering"),
+
 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
+      ngx_conf_set_flag_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),
+      NULL },
+
    { ngx_string("uwsgi_ignore_client_abort"),
      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
      ngx_conf_set_flag_slot,
@@ -445,7 +452,7 @@
    u->abort_request = ngx_http_uwsgi_abort_request;
    u->finalize_request = ngx_http_uwsgi_finalize_request;

-    u->buffering = 1;
+    u->buffering = uwcf->upstream.buffering;

    u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
    if (u->pipe == NULL) {
@@ -1083,6 +1090,8 @@
    /* "uwsgi_cyclic_temp_file" is disabled */
    conf->upstream.cyclic_temp_file = 0;

+    conf->upstream.change_buffering = 1;
+
    ngx_str_set(&conf->upstream.module, "uwsgi");

    return conf;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20110923/c44f9a30/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-1.1.0_uwsgi_buffering_patch
Type: application/octet-stream
Size: 1252 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20110923/c44f9a30/attachment.obj>


More information about the nginx-devel mailing list