Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1481380
  • 博文数量: 228
  • 博客积分: 1698
  • 博客等级: 上尉
  • 技术积分: 3241
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-24 21:49
个人简介

Linux

文章分类

全部博文(228)

文章存档

2017年(1)

2016年(43)

2015年(102)

2014年(44)

2013年(5)

2012年(30)

2011年(3)

分类: LINUX

2017-04-28 00:58:32

http://blog.csdn.net/mikemiller2/article/details/50554183

点击(此处)折叠或打开

  1. Nginx HTTP请求流程,有需要的朋友可以参考下。

  2. | \-- ngx_single_process_cycle
  3. ##########################################################################
  4. ##########################################################################
  5. | | \-- ngx_process_events_and_timers
  6. | | | \-- ngx_event_find_timer
  7. | | | \-- ngx_epoll_process_events //ngx_process_events
  8.                     epoll_wait() //block here //
  9. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  10. !---> Event: client send first TCP connect request
  11. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12. | | | | \-- ngx_time_update
  13. | | | | \-- ngx_event_accept // accept a connection, add the read event and ngx_http_init_request handler to epoll
  14.                         accept() //noblock read, get the new client socket
  15. | | | | | \-- ngx_get_connection
  16. | | | | | \-- ngx_create_pool //create connection pool
  17. | | | | | \-- ngx_nonblocking // nonelock client socket
  18. | | | | | \-- ngx_sock_ntop
  19. | | | | | \-- ngx_http_init_connection //ls->handler, set the next read event handler to ngx_http_init_request
  20. | | | | | | \-- ngx_event_add_timer
  21. | | | | | | \-- ngx_handle_read_event // add the next read event to epoll
  22. | | | | | | | \-- ngx_epoll_add_event
  23. | | | \-- ngx_event_expire_timers
  24. | | | | \-- ngx_rbtree_min
  25. ##########################################################################
  26. ##########################################################################
  27. | | \-- ngx_process_events_and_timers
  28. | | | \-- ngx_event_find_timer
  29. | | | \-- ngx_epoll_process_events //ngx_process_events
  30.                     epoll_wait() //block here //
  31. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  32. !---> Event: client send first HTTP request
  33. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  34. | | | | \-- ngx_time_update
  35. | | | | \-- ngx_http_init_request //call ngx_http_process_request_line, till send out the request
  36. | | | | | \-- ngx_http_process_request_line
  37. | | | | | | \-- ngx_http_read_request_header
  38. | | | | | | \-- ngx_http_parse_request_line //parse method, URL, version
  39. | | | | | | \-- ngx_http_process_request_headers
  40. | | | | | | | \-- ngx_http_read_request_header // read all headers
  41. | | | | | | | \-- ngx_http_parse_header_line // header 1
  42. | | | | | | | \-- ngx_list_push
  43. | | | | | | | \-- ngx_pnalloc
  44. | | | | | | | \-- ngx_hash_find
  45. | | | | | | | \-- ngx_http_process_user_agent //header 1 handler
  46. | | | | | | | \-- ngx_http_parse_header_line // header 2
  47. | | | | | | | \-- ngx_list_push
  48. | | | | | | | \-- ngx_pnalloc
  49. | | | | | | | \-- ngx_hash_find
  50. | | | | | | | \-- ngx_http_process_host //header 2 handler
  51. | | | | | | | \-- ngx_http_parse_header_line //header 3
  52. | | | | | | | \-- ngx_list_push
  53. | | | | | | | \-- ngx_pnalloc
  54. | | | | | | | \-- ngx_hash_find
  55. | | | | | | | \-- ngx_http_parse_header_line // no more header
  56. | | | | | | | \-- ngx_http_process_request_header
  57. | | | | | | | | \-- ngx_http_find_virtual_server
  58. | | | | | | | \-- ngx_http_process_request
  59. | | | | | | | | \-- ngx_event_del_timer
  60. | | | | | | | | \-- ngx_http_handler
  61. | | | | | | | | | \-- ngx_http_core_run_phases
  62. | | | | | | | | | | \-- ngx_http_core_rewrite_phase //phase checker
  63. | | | | | | | | | | | \-- ngx_http_rewrite_handler //phase handler
  64. | | | | | | | | | | \-- ngx_http_core_find_config_phase
  65. | | | | | | | | | | | \-- ngx_http_core_find_location
  66. | | | | | | | | | | | \-- ngx_http_update_location_config
  67. | | | | | | | | | | \-- ngx_http_core_rewrite_phase
  68. | | | | | | | | | | | \-- ngx_http_rewrite_handler
  69. | | | | | | | | | | \-- ngx_http_core_post_rewrite_phase
  70. | | | | | | | | | | \-- ngx_http_core_generic_phase
  71. | | | | | | | | | | | \-- ngx_http_limit_req_handler
  72. | | | | | | | | | | \-- ngx_http_core_generic_phase
  73. | | | | | | | | | | | \-- ngx_http_limit_conn_handler
  74. | | | | | | | | | | \-- ngx_http_core_access_phase
  75. | | | | | | | | | | | \-- ngx_http_access_handler
  76. | | | | | | | | | | \-- ngx_http_core_access_phase
  77. | | | | | | | | | | | \-- ngx_http_auth_basic_handler
  78. | | | | | | | | | | \-- ngx_http_core_post_access_phase
  79. | | | | | | | | | | \-- ngx_http_core_content_phase
  80. | | | | | | | | | | | \-- ngx_http_index_handler
  81. | | | | | | | | | | | | \-- ngx_http_map_uri_to_path
  82. | | | | | | | | | | | | \-- ngx_http_set_disable_symlinks
  83. | | | | | | | | | | | | \-- ngx_open_cached_file
  84. | | | | | | | | | | | | | \-- ngx_file_info_wrapper
  85. | | | | | | | | | | | | \-- ngx_http_internal_redirect
  86. | | | | | | | | | | | | | \-- ngx_http_set_exten
  87. | | | | | | | | | | | | | \-- ngx_http_update_location_config
  88. | | | | | | | | | | | | | \-- ngx_http_handler
  89. | | | | | | | | | | | | | | \-- ngx_http_core_run_phases
  90. | | | | | | | | | | | | | | | \-- ngx_http_core_rewrite_phase
  91. | | | | | | | | | | | | | | | | \-- ngx_http_rewrite_handler
  92. | | | | | | | | | | | | | | | \-- ngx_http_core_find_config_phase
  93. | | | | | | | | | | | | | | | | \-- ngx_http_core_find_location
  94. | | | | | | | | | | | | | | | | \-- ngx_http_update_location_config
  95. | | | | | | | | | | | | | | | \-- ngx_http_core_rewrite_phase
  96. | | | | | | | | | | | | | | | | \-- ngx_http_rewrite_handler
  97. | | | | | | | | | | | | | | | \-- ngx_http_core_post_rewrite_phase
  98. | | | | | | | | | | | | | | | \-- ngx_http_core_generic_phase
  99. | | | | | | | | | | | | | | | | \-- ngx_http_limit_req_handler
  100. | | | | | | | | | | | | | | | \-- ngx_http_core_generic_phase
  101. | | | | | | | | | | | | | | | | \-- ngx_http_limit_conn_handler
  102. | | | | | | | | | | | | | | | \-- ngx_http_core_access_phase
  103. | | | | | | | | | | | | | | | | \-- ngx_http_access_handler
  104. | | | | | | | | | | | | | | | \-- ngx_http_core_access_phase
  105. | | | | | | | | | | | | | | | | \-- ngx_http_auth_basic_handler
  106. | | | | | | | | | | | | | | | \-- ngx_http_core_post_access_phase
  107. | | | | | | | | | | | | | | | \-- ngx_http_core_content_phase
  108. | | | | | | | | | | | | | | | | \-- ngx_http_index_handler
  109. | | | | | | | | | | | | | | | \-- ngx_http_core_content_phase
  110. | | | | | | | | | | | | | | | | \-- ngx_http_autoindex_handler
  111. | | | | | | | | | | | | | | | \-- ngx_http_core_content_phase
  112. | | | | | | | | | | | | | | | | \-- ngx_http_static_handler
  113. | | | | | | | | | | | | | | | | | \-- ngx_http_map_uri_to_path
  114. | | | | | | | | | | | | | | | | | \-- ngx_http_set_disable_symlinks
  115. | | | | | | | | | | | | | | | | | \-- ngx_open_cached_file
  116. | | | | | | | | | | | | | | | | | \-- ngx_http_discard_request_body
  117. | | | | | | | | | | | | | | | | | \-- ngx_http_set_content_type
  118. | | | | | | | | | | | | | | | | | \-- ngx_http_send_header
  119. | | | | | | | | | | | | | | | | | | \-- ngx_http_not_modified_header_filter
  120. | | | | | | | | | | | | | | | | | | | \-- ngx_http_headers_filter
  121. | | | | | | | | | | | | | | | | | | | | \-- ngx_http_userid_filter
  122. | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_charset_header_filter
  123. | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_destination_charset
  124. | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_ssi_header_filter
  125. | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_gzip_header_filter
  126. | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_range_header_filter
  127. | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_list_push
  128. | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_chunked_header_filter
  129. | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_header_filter
  130. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_create_temp_buf
  131. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_sprintf
  132. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_time
  133. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_write_filter
  134. | | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_alloc_chain_link
  135. | | | | | | | | | | | | | | | | | \-- ngx_http_output_filter
  136. | | | | | | | | | | | | | | | | | | \-- ngx_http_range_body_filter
  137. | | | | | | | | | | | | | | | | | | | \-- ngx_http_copy_filter
  138. | | | | | | | | | | | | | | | | | | | | \-- ngx_output_chain
  139. | | | | | | | | | | | | | | | | | | | | | \-- ngx_output_chain_as_is
  140. | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_charset_body_filter
  141. | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_ssi_body_filter
  142. | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_postpone_filter
  143. | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_gzip_body_filter
  144. | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_chunked_body_filter
  145. | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_http_write_filter
  146. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_alloc_chain_link
  147. | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_linux_sendfile_chain
  148. | | | | | | | | | | | | | | | | | | | | | | | | | | | | \-- ngx_array_push
  149.                                                                                                                     sendfile() //actually sent out
  150. | | | | | | | | | | | | | | | | \-- ngx_http_finalize_request
  151. | | | | | | | | | | | | | | | | | \-- ngx_http_post_action
  152. | | | | | | | | | | | | | | | | | \-- ngx_http_finalize_connection
  153. | | | | | | | | | | | | | | | | | | \-- ngx_http_close_request
  154. | | | | | | | | | | | \-- ngx_http_finalize_request
  155. | | | | | | | | | | | | \-- ngx_http_finalize_connection
  156. | | | | | | | | | | | | | \-- ngx_http_set_keepalive
  157. | | | | | | | | | | | | | | \-- ngx_http_free_request
  158. | | | | | | | | | | | | | | | \-- ngx_http_log_request
  159. | | | | | | | | | | | | | | | \-- ngx_destroy_pool
  160. | | | | | | | | | | | | | | \-- ngx_event_add_timer //leeplive timeout
  161. | | | | | | | | | | | | | | \-- ngx_handle_read_event //add read event
  162. | | | | | | | | | | | | | | \-- ngx_reusable_connection
  163. | | | | | | | | \-- ngx_http_run_posted_requests
  164. | | | \-- ngx_event_expire_timers
  165. | | | \-- ngx_event_process_posted
  166. | | | | \-- ngx_http_keepalive_handler
  167. | | | | | \-- ngx_palloc
  168. | | | | | | \-- ngx_palloc_large
  169. | | | | | | | \-- ngx_alloc
  170. | | | | | \-- ngx_unix_recv
  171. | | | | | \-- ngx_handle_read_event
  172. | | | | | \-- ngx_pfree
  173. ##########################################################################
  174. ##########################################################################
  175. | | \-- ngx_process_events_and_timers
  176. | | | \-- ngx_event_find_timer
  177. | | | \-- ngx_epoll_process_events //ngx_process_events
  178.                     epoll_wait() //block here //
  179. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  180. !---> Event: timeout for the connection
  181. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  182. | | | | \-- ngx_time_update
  183. | | | | \-- ngx_http_keepalive_handler
  184. | | | | | \-- ngx_unix_recv
  185. | | | | | \-- ngx_http_close_connection
  186. | | | | | | \-- ngx_close_connection
  187. | | | | | | \-- ngx_destroy_pool
  188. | | | \-- ngx_event_expire_timers
  189. ##########################################################################
  190. ##########################################################################
  191. | | \-- ngx_process_events_and_timers
  192. | | | \-- ngx_event_find_timer
  193. | | | \-- ngx_epoll_process_events //ngx_process_events
  194.                     epoll_wait() //block here //
  195. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  196. !---> Event: Client send a new TCP connect request
  197. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  198. | | | | \-- ngx_time_update
  199. | | | | \-- ngx_event_accept
  200. | | | | | \-- ngx_get_connection
  201. | | | | | \-- ngx_create_pool
  202. | | | | | | \-- ngx_memalign
  203. | | | | | \-- ngx_palloc
  204. | | | | | \-- ngx_palloc
  205. | | | | | \-- ngx_nonblocking
  206. | | | | | \-- ngx_atomic_fetch_add
  207. | | | | | \-- ngx_pnalloc
  208. | | | | | \-- ngx_sock_ntop
  209. | | | | | \-- ngx_http_init_connection
  210. | | | | | | \-- ngx_palloc
  211. | | | | | | \-- ngx_event_add_timer
  212. | | | | | | \-- ngx_handle_read_event
  213. | | | | | | | \-- ngx_epoll_add_event
  214. | | | \-- ngx_event_expire_timers
  215. | | | | \-- ngx_rbtree_min
  216. ##########################################################################
  217. ##########################################################################
  218. | | \-- ngx_process_events_and_timers
  219. | | | \-- ngx_event_find_timer
  220. | | | | \-- ngx_rbtree_min
  221. | | | \-- ngx_epoll_process_events //ngx_process_events
  222.                     epoll_wait() //block here //
  223. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  224. !---> Event: Client send a new HTTP request
  225. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  226. | | | | \-- ngx_time_update
  227. | | | | \-- ngx_http_init_request
  228. | | | | | \-- ngx_http_process_request_line
  229. ...

阅读(3442) | 评论(2) | 转发(0) |
0

上一篇:Linux常用性能调优工具索引

下一篇:没有了

给主人留下些什么吧!~~

s977122017-05-07 01:05:56

s97712:老大这是工具生成的还是你自己分析的啊

刚刚没看到转字,我找找出处

回复 | 举报

s977122017-05-07 01:04:34

老大这是工具生成的还是你自己分析的啊