幼麟 封
December 31, 2021 09:26AM
Hello, Maxim!

You are right, we can’t completely avoid this kind of problem, but we can reduce some. Maybe "keepalive_graceful_close" is not exact, it should be "wait_keepalive_on_exit". I mean, with this patch, I want to optimize the connection closure problem caused by the exit of the work process, is an optimization for a specific scene. By setting a shorter expiration time for the keepalived connection on the client side than the "keepalive_timeout" on the nginx side, we can really reduce the number of client retries.

Regards and happy new year.

From: Maxim Dounin<mailto:mdounin@mdounin.ru>
Sent: 2021年12月29日 0:20
To: nginx-devel@nginx.org<mailto:nginx-devel@nginx.org>
Subject: Re: [PATCH] HTTP: keepalive_graceful_close support

Hello!

On Tue, Dec 28, 2021 at 03:36:22PM +0000, 封 幼麟 wrote:

> In my scenario, nginx is used with consul-template as a load
> balancer that implements service discovery. Each time a service
> instance is registered to or unregistered from
> consul,consul-template will trigger all nginx instances to
> reload. In a busy system, this happens very frequently, and each
> reload will cause many "keepalived" connections to be closed.
> The client based on golang got a lot of "server closed idle
> connection" and "EOF" errors.

The "server closed idle connection" doesn't look like an error at
all. Not sure what "EOF" means, but either way it looks more like
an issue in the client than something to address in nginx.

> Of course, the client should implement the "auto retry" logic,
> but I think we have a better way to completely solve this
> problem in nginx. My idea is, don't treat the keepalived http
> connections as idle connections, and send a "Connection: close"
> header in the next response. If no more requests come, the
> worker process will wait until "keepalive_timeout", then exit,
> and won't wait long. So, if we give the client a smaller
> "IdleConnTimeout", there is no race now. If someone doesn't want
> to use this patch, just leave "keepalive_graceful_close" unset.

To re-iterate: even with your patch (which basically returns the
nginx behaviour before 0.5.15), the race is still here, since
there are cases when keepalive connections are closed (notably,
when keepalive_timeout expires, or when there are no free
connections). That is, the patch basically tries to hide client
issues in some common case at the cost of keeping old worker
processes alive till keepalive_timeout expiration. Still, these
issues can re-appear in other cases, and the only complete
solution can be implemented on the client.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] HTTP: keepalive_graceful_close support

Youlin Feng 514 December 17, 2021 01:00AM

Re: [PATCH] HTTP: keepalive_graceful_close support

Maxim Dounin 178 December 27, 2021 09:10AM

Re: [PATCH] HTTP: keepalive_graceful_close support

封 幼麟 160 December 28, 2021 10:38AM

Re: [PATCH] HTTP: keepalive_graceful_close support

Maxim Dounin 146 December 28, 2021 11:22AM

RE: [PATCH] HTTP: keepalive_graceful_close support

幼麟 封 129 December 31, 2021 09:26AM

Re: [PATCH] HTTP: keepalive_graceful_close support

Maxim Dounin 206 January 10, 2022 08:14PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 179
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