nginx 에서 uptream 접근 처리

2523 단어 서버 개발
nginx 는 upstream 방문 에 대한 처리 가 매우 이상 하 다 고 말 할 수 는 없 지만 적어도 매우 다르다.처리 프로 세 스에 서 모든 upstream 에 대해 접근 할 때 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=) 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 , 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

좋은 웹페이지 즐겨찾기