Use of upstream keepalive_time

Maxim Dounin mdounin at mdounin.ru
Fri Feb 3 03:16:33 UTC 2023


Hello!

On Thu, Feb 02, 2023 at 01:03:13PM +0530, Vishwas Bm wrote:

> Can this keepalive_time be made infinite ?
> So that connection is not broken after default 1hr

There is no specific infinite value, though you can use a large 
enough keepalive_time instead.  Something like "keepalive_time 10d;" 
should be a good replacement for "infinite".

Note though that this might not be a good idea for the reasons 
outlined in the previous response.

[...]

> > The "keepalive_time" is a directive to limit total lifetime of the
> > connection, making it possible to free any resources associated
> > with the connection, notably allocated memory.  Further, in some
> > setups it might be important to periodically redo connection
> > authentication, notably re-validate peer certificates.
> >
> > The "keepalive_time" directive is mostly equivalent to
> > keepalive_requests, which is documented as follows:
> >
> > : Closing connections periodically is necessary to free
> > : per-connection memory allocations. Therefore, using too high
> > : maximum number of requests could result in excessive memory usage
> > : and not recommended.
> >
> > Note though that keepalive_time is 1 hour by default, and reopening
> > connections once per hour is not expected to have any performance
> > impact.  Rather, it is expected to be a hard limit on the total
> > connection lifetime on connections which are mostly idle and
> > therefore do not reach the "keepalive_requests" limit in a
> > reasonable time.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list