Pre briefing:
Although my question is broad on purpose, I am dealing with nginx connecting to php-fpm (fcgi), which is served via a local socket (/tmp/somesocket.socket).
Nginx has a setting to keepalive connections to fcgi backends ( http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_keep_conn ).
This is what my question relates to.
Question:
In linux, when making connection to local sockets, does such a thing as keepalives exist?
Would having a connection kept alive remove (even a tiny bit) some overhead related to creation / teardown of the connection?
Thanks.
I am assuming you mean local unix sockets here.
No, keepalives prevent the remote side timing out. Since the host knows the status of both sides of the connection a keepalive is redundant.
Yes, at the cost of maintaining more file descriptors which is probably a very cheap cost in practical terms. Setting up a connection and closing it incurs 5 system calls (open and connect on client, accept on server, close on client/server) which with maintaining the connection is avoided until necessary.