Hi, 

I want to add a postpone mode to nginx for transfer data to upstream as 
described bellow. Any opinions?


##Purpose
Purpose of this change is to provide a mode among nginx non-buffered mode and 
buffered mode. We call this mode `postpone mode`. In this mode, 1) request body 
is transferred to upstream in a bulk mode. 2) Connection to upstream is 
established on first time transferring. 


##implementation
1. Use a ping-pong buffer to receive client request body.
    By default, nginx use only one buffer (i.e. request_body->buf) to receive 
client request body. When this buffer is full nginx will stop receiving and 
wait it to be free (wait `rb->busy` to be null). 
    A ping-pong buffer will reduce the chance of waiting. When one buffer is 
used for upstream sending, the other buffer can be used to receive client data.
   In postpone mode, receive buffer (`rb->buf`) is send to upstream only when 
it is full. This is different than the original nginx behavior, that send 
received data to upstream immediately regardless of the data length.
   
2. The moment to call `ngx_http_upstream_init`
    `ngx_http_upstream_init` is called to establish connection  to upstream. By 
default, nginx call this function in two places depends on upstream transfer 
mode.
    - for buffered mode, this init function is called after whole request body 
is received and buffered.
    - for non-buffered mode, this init function is called after first call to 
`ngx_http_do_read_client_request_body` in `ngx_http_read_client_request_body` 
regardless the whole body is received or not.
    For postpone mode, the init function will be called on first time there's 
need send data to upstream. i.e. the first time the receive buffer is full, 
since postpone mode transfer data when receive buffer is full.


Best Regards
LiuLele



_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to