Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 2.05 KB

nginx.org

File metadata and controls

68 lines (53 loc) · 2.05 KB

tcp惊群问题的解决

这里分析的很详细[fn:1] 当前worker的数量为配置的7/8以上时会set: ngx_accept_disabled

http process

key function:

ngx_http_process_request_line -> ngx_http_read_request_header -> ngx_http_parse_request_line htt parser -> ngx_http_parse_header_line

ngx_http_headers_in header -> process function map e.g.

ngx_http_header_t  ngx_http_headers_in[] = {
    { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host),
                 ngx_http_process_host },

    { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection),
                 ngx_http_process_connection },
...
...

when is header process done? ==> NGX_HTTP_PARSE_HEADER_DONE, (two \n\n indicate header finish)

    if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
...
        ngx_http_process_request(r);
...
    }

ngx_http_process_request detail:

c->read->handler = ngx_http_request_handler;
c->write->handler = ngx_http_request_handler;
r->read_event_handler = ngx_http_block_reading;

final http process function:

ngx_http_core_run_phases

key data structure

ngx_str_t : nginx/src/core/ngx_string.h:13

ngx_pool_t : nginx/src/core/ngx_palloc.h:57

woker loop:

ngx_worker_process_cycle -> ngx_process_events_and_timers

command line tool

-v Print version. -V Print NGINX version, compiler version and configure parameters. -t Don’t run, just test the configuration file. NGINX checks configuration for correct syntax and then try to open files referred in configuration. -q Suppress non-error messages during configuration testing. -s signal Send signal to a master process: stop, quit, reopen, reload. (version >= 0.7.53) -p prefix Set prefix path (default: usr/local/nginx). (version >= 0.7.53) -c filename Specify which configuration file NGINX should use instead of the default. -g directives Set global directives. (version >= 0.7.4)

Footnotes

[fn:1] http://blog.csdn.net/russell_tao/article/details/7204260