nginx中對uptream訪問的處理

WBOY
發布: 2016-07-29 09:00:40
原創
1070 人瀏覽過

nginx對upstream存取的處理非常的,不能說奇怪,但也至少是很另類。在處理的流程中,針對每個upsream,在訪問到的時候,再建立socket,然後綁定upstream的地址,然後針對此upstream進行讀,然後再關閉。這麼處理非常違反開發直覺,在做遊戲伺服器的時候,對於socket這種系統資源,是在系統啟動時候預先建立好,然後再整個伺服器運行的過程中都保持連接,當單獨的socket斷開時,並不是關閉此socket, 而是將此socket重新賦值給新的連線。

看看下面的流程,會很讓人震驚的

(gdb) bt
#0  ngx_event_connect_peer (pc=0x9c1e6d8) at src/event/ngx_event_connect.c:32
#1  0x0808cd9b in ngx_http_upstream_connect (r=0x9c1de38, u=0x9c1e6d0) at src/http/ngx_http_upstream.c:1368
#2  0x0808bd82 in ngx_http_upstream_init_request (r=0x9c1de38) at src/http/ngx_http_upstream.c:772
#3  0x0808b61d in ngx_http_upstream_init (r=0x9c1de38) at src/http/ngx_http_upstream.c:523
#4  0x080bc5d7 in ngx_http_memcached_handler (r=0x9c1de38) at src/http/modules/ngx_http_memcached_module.c:224
#5  0x0807a37b in ngx_http_core_content_phase (r=0x9c1de38, ph=0x9c33db8) at src/http/ngx_http_core_module.c:1363
#6  0x08075828 in ngx_http_core_run_phases (r=0x9c1de38) at src/http/ngx_http_core_module.c:840
#7  0x0807594a in ngx_http_handler (r=<optimized out>) at src/http/ngx_http_core_module.c:823
#8  0x0807d281 in ngx_http_process_request (r=0x9c1de38) at src/http/ngx_http_request.c:1910
#9  0x0807fa89 in ngx_http_process_request_headers (rev=0x78a930c8) at src/http/ngx_http_request.c:1342
#10 0x0807fd3e in ngx_http_process_request_line (rev=0x78a930c8) at src/http/ngx_http_request.c:1022
#11 0x08080691 in ngx_http_wait_request_handler (rev=0x78a930c8) at src/http/ngx_http_request.c:499
#12 0x08072a91 in ngx_epoll_process_events (cycle=0x9c185e8, timer=60000, flags=1) at src/event/modules/ngx_epoll_module.c:822
#13 0x0806abbc in ngx_process_events_and_timers (cycle=0x9c185e8) at src/event/ngx_event.c:242
#14 0x08070ebc in ngx_worker_process_cycle (cycle=0x9c185e8, data=0x0) at src/os/unix/ngx_process_cycle.c:753
#15 0x0806f932 in ngx_spawn_process (cycle=0x9c185e8, proc=0x8070e2a <ngx_worker_process_cycle>, data=0x0, name=0x80d540a "worker process", 
    respawn=-3) at src/os/unix/ngx_process.c:198
#16 0x08070338 in ngx_start_worker_processes (cycle=cycle@entry=0x9c185e8, n=1, type=type@entry=-3) at src/os/unix/ngx_process_cycle.c:358
#17 0x080716a5 in ngx_master_process_cycle (cycle=0x9c185e8) at src/os/unix/ngx_process_cycle.c:130
#18 0x08052669 in main (argc=1, argv=0xbfaeb814) at src/core/nginx.c:367
登入後複製

以上就介紹了nginx中對uptream訪問的處理,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板