简体   繁体   English

Nginx + FastCGI阻止呼叫

[英]Nginx + FastCGI with blocking calls

The main advantage of Nginx is cited as it not needing to spawn separate threads for each request it receives. Nginx的主要优点是它不需要为收到的每个请求生成单独的线程。

Now, if we were to run a python based web application using FastCGI, and this web application has blocking calls, would this create a bottleneck? 现在,如果我们要使用FastCGI运行基于python的Web应用程序,并且该Web应用程序具有阻塞调用,这会造成瓶颈吗?

Since there is only a limited number of workers running(1 per processor?), wont a blocking call by a python script make it cooperative multiprocessing? 由于仅运行有限数量的工作程序(每个处理器1个?),python脚本的阻塞调用是否会使它协同进行多处理?

Nginx talks to a fastcgi process over a socket connection. Nginx通过套接字连接与fastcgi进程进行对话。

If the fastcgi process blocks, that means that it won't be sending data over the socket. 如果fastcgi进程阻塞,则意味着它将不会通过套接字发送数据。

This won't block nginx as such, because it keeps processing events (data from other connections). 这样不会阻塞nginx,因为它会继续处理事件(来自其他连接的数据)。 It uses non-blocking techniques like select , poll or equivalent OS-dependent functions (with a timeout) to query sockets without blocking. 它使用诸如selectpoll或等效的依赖于OS的函数(具有超时)之类的非阻塞技术来查询套接字而不会阻塞。

But it will stall whatever client is waiting for the fastcgi output. 但是无论客户端正在等待fastcgi输出,它将停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM