nginx source in the upstream of the main flow

upstream  i.e., upstream of the means is a want to concept from the client to a network link to the intermediate link to the server, the client may be closer to the device to be understood that the downstream, upstream to the contrary, if there is only one upstream, it can be understood as a client to forward the request to the server, the server then forwards the response to the client process, the main flow source is as follows:

 

1 , created upstream           

ngx_http_upstream_init

  Delete timeout timer

  Create request to the upstream

  Hook some processing functions, including the first after the end of step 6 to use to request upstream to the cleanup function

2, to establish a connection with the upstream

ngx_http_upstream_connect

    Create Socket , the connetion , tcp initiate setting up a connection request, using epoll transmission request, mounted upstream of the Handler , including 4 , 5 handler upstream process step response

 

3, a request is sent to the upstream 

ngx_http_upstream_send_request

4, the process upstream of the response header

process_header resolution request header

ngx_http_upstream_process_headers processing request header

 

5, the processing in response to the body upstream of the

ngx_http_upstream_process_body_in_memory

If you need to forward the appropriate body, you can achieve their own input_filter , if it is to achieve its own default ngx_http_upstream_non_buffered_filter

 ( 1) speed between the upstream and the upstream is high, the memory, and even large files, the cache requests the upstream large

 ( 2) when the fast speed between the upstream and downstream, a fixed memory size, cache request without undue

ngx_http_upstream_send_response by determining

buffering decided to take the process described above

 

6 , the end of the upstream request

ngx_http_upstream_cleanup

The main release of some of the resources used upstream

Guess you like

Origin www.cnblogs.com/bewolf/p/10960450.html