Nginx keepalive when using a UNIX socket

nginxsocket

Is there any benefit or performance gain when using keepalive on an upstream that is using a UNIX socket as a server, for example:

upstream test {
    server unix:/tmp/test.sock;
    keepalive 60;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;

    location / {
        proxy_pass http://test;
        proxy_http_version 1.1;  
        proxy_redirect off;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

From my understanding when using a UNIX socket there is no TCP three-way handshake so the keepalive 60; in the example don't apply, is this correct?

Best Answer

UNIX sockets are still connections so the nginx keepalive is a cache of these, and it doesn't matter what happens at the lower levels.

keepalive here isn't the same as many other tools/services where those implies something is sent/received to maintain the connection.