sockets - Whether the connection between php-fpm and nginx by fast-cgi are persistent (keep-alive) connection? -


i trying write server demo connect php-fpm , don't know whether connection between php-fpm , nginx fast-cgi persistent (keep-alive) connection? every time when http request nginx , nginx connect php-fpm tcp 3-way handshake again ? or connection between nginx , php-fpm keep-alive connect , nginx try reuse ?

php-fpm implementation of fastcgi protocol, , such abides fastcgi specification requirements.

one such requirement in section 3.5 of specification, closing connections:

the web server controls lifetime of transport connections. web server can close connection when no requests active. or web server can delegate close authority application (see fcgi_begin_request). in case application closes connection @ end of specified request. flexibility accommodates variety of application styles. simple applications process 1 request @ time , accept new transport connection each request. more complex applications process concurrent requests, on 1 or multiple transport connections, , keep transport connections open long periods of time.

a simple application gets significant performance boost closing transport connection when has finished writing response. web server needs control connection lifetime long-lived connections.

when application closes connection or finds connection has closed, application initiates new connection.

this means webserver decide whether connection persist or not. implemented in nginx via fastcgi_keep_conn option states:

by default, fastcgi server close connection right after sending response. however, when directive set value on, nginx instruct fastcgi server keep connections open. necessary, in particular, keepalive connections fastcgi servers function.

this statement reflect specification behaviour capability of webserver can serve fastcgi generated content modify default behaviour.

my assumption here there no real point keep connections alive since threads of webservers recycled. perhaps there's specified number of parked threads usual policy of thread pooling kill least used thread, means spawning new thread ensure pre-exiting threads ones killed.

admittedly have found no resource claim pool collection policy of nginx lru it's not unlikely , in case keeping connection alive not save much.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -