Welcome! Log In Create A New Profile

Advanced

Re: Use of upstream keepalive_time

Maxim Dounin
January 20, 2023 07:04PM
Hello!

On Fri, Jan 20, 2023 at 11:37:15AM +0530, Vishwas Bm wrote:

> I see that from 1.19.10 keepalive_time has been added.
> http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time
>
> Also keepalive_timeout is present for idle connection
> http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout
>
> On checking the behaviour between these two, I see that keepalive_time is
> having higher precedence over keepalive_timeout.
> Even if connection is not idle based on keepqlive_timeout, connection is
> still getting closed because of keepalive_time.
>
> Is this expected behaviour?
> Also can I set keepalive_time to higher value say 24hours ? Any drawbacks
> with this ?
> Can this keepalive_time be disabled and priority given only to
> keepalive_timeout ?

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/
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Use of upstream keepalive_time

Vishwas Bm January 20, 2023 01:08AM

Re: Use of upstream keepalive_time

Maxim Dounin January 20, 2023 07:04PM

Re: Use of upstream keepalive_time

Vishwas Bm February 02, 2023 02:34AM

Re: Use of upstream keepalive_time

Maxim Dounin February 02, 2023 10:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready