15

Which is the better configuration/optimization: to explicitly limit the keepalive_timeout or to allow Nginx to kill keepalive connections on its own?

I have seen two conflicting recommendations regarding the keepalive_timeout directive for Nginx. They are as follows:

# How long to allow each connection to stay idle; longer values are better
# for each individual client, particularly for SSL, but means that worker
# connections are tied up longer. (Default: 65)
keepalive_timeout  20;

and

# You should remove keepalive_timeout from your formula.
# Nginx closes keepalive connections when the
# worker_connections limit is reached.

The Nginx documentation for keepalive_timeout makes no mention of the automatic killing, and I have only seen this recommendation once, but it intrigues me.

This server serves exclusively TLS-secured connections, and all non-encrypted connections are immediately rerouted to the https:// version of the same URL.

Bryson
  • 263
  • 1
  • 2
  • 9

1 Answers1

14

Nginx closes keepalive connections when the worker_connections limit is reached.

That's true.

VBart
  • 8,159
  • 3
  • 24
  • 25