I’d like to understand how
keepalive_timeout works. The description
in the documentation isn’t very clear and I couldn’t get an answer to
my satisfaction on nginx IRC.
People seem to have their own understanding of how
works and they are very different.
describes the directive like this:
# for each individual client, particularly for SSL, but means that
# connections are tied up longer. (Default: 65)
So according to the statement
keepalive_timeout is to be used to
tell how long a server needs to keep the connection alive AFTER
serving all the requests.
And this commenter seems to agree:
[It’s] only a timeout during which server waits for another request
up to [the limit set by]
keepalive_requests. So it is not important
how much time it takes for the full page to load […] BTW the max.
time connection is kept open is almost:
keepalive_timeout * keepalive_requests
- Then there are people understand the function of
keepalive_timeoutlike so: HTTP Keep Alive and TCP keep alive - Stack Overflow
HTTP Keep-Alive is a feature of HTTP protocol. The web-server,
implementing Keep-Alive Feature, has to check the connection/socket
periodically (for incoming HTTP request) for the time span since it
sent the last HTTP response (in case there was corresponding HTTP
Request). If no HTTP request is received by the time of the configured
keep-alive time (seconds) the web server closes the connection.
Similar opinion from another: keepalive - How to adjust nginx keepalive_timeout? - Server Fault
There isn’t a good one-size-fits-all answer; if most client browsers
are able to load all the resources on a page in 5 seconds then 5
seconds is just fine […]
So according to these people the directive is to be calculated in such
a way that in that given time (on an average) a web page on your site
and its contents (HTML, CSS, JS, images) are completely loaded on most
THE QUESTION: So which one is it? (1) or (2)? Who’s right?