• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

nginx中对uptream访问的处理

php 搞代码 4年前 (2022-01-23) 45次浏览 已收录 0个评论

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  0x0807*本5文来源gaodai$ma#com搞$$代**码)网@搞代码gaodaima5828 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

以上就介绍了nginx中对uptream访问的处理,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:nginx中对uptream访问的处理
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址