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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.