PHP-FPM是fastCGI协议的一种实现,因此它遵守所有fastCGI规范要求.
The Web server controls the lifetime of transport connections. The Web server can close a connection when no requests are active. Or the Web server can delegate close authority to the application (see FCGI_BEGIN_REQUEST). In this case the application closes the connection at the end of a specified request.
This flexibility accommodates a variety of application styles. Simple applications will process one request at a time and accept a new transport connection for each request. More complex applications will process concurrent requests, over one or multiple transport connections, and will keep transport connections open for long periods of time.
A simple application gets a significant performance boost by closing the transport connection when it has finished writing its response. The Web server needs to control the connection lifetime for long-lived connections.
When an application closes a connection or finds that a connection has closed, the application initiates a new connection.
这意味着由Web服务器决定连接是否会持续存在.这是通过fastcgi_keep_conn选项在nginx中实现的,该选项指出:
By default, a FastCGI server will close a connection right after sending the response. However, when this directive is set to the value on, nginx will instruct a FastCGI server to keep connections open. This is necessary, in particular, for keepalive connections to FastCGI servers to function.
此语句用于反映规范行为以及可以为fastCGI生成的内容提供服务以修改默认行为的Web服务器的功能.
我的假设是,由于网络服务器的线程不断被回收,因此保持连接不存在真正的意义.也许有一定数量的停放线程,但通常的线程池策略是杀死least recently used线程,通常这意味着产生一个新线程将确保预先退出的线程被杀死.
不可否认,我没有找到任何资源来支持nginx的池收集策略是LRU的说法,但它不是不可能的,在这种情况下保持连接存活不会节省太多.