<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:DengXian;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="ZH-CN" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hello, Maxim!</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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.</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Regards and happy new year.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b><span lang="EN-US">From: </span>
</b><span lang="EN-US"><a href="mailto:mdounin@mdounin.ru">Maxim Dounin</a><br>
<b>Sent: </b>2021</span>年<span lang="EN-US">12</span>月<span lang="EN-US">29</span>日<span lang="EN-US"> 0:20<br>
<b>To: </b><a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<b>Subject: </b>Re: [PATCH] HTTP: keepalive_graceful_close support</span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Hello!<br>
<br>
On Tue, Dec 28, 2021 at 03:36:22PM +0000, </span>封 幼麟<span lang="EN-US"> wrote:<br>
<br>
> In my scenario, nginx is used with consul-template as a load <br>
> balancer that implements service discovery. Each time a service <br>
> instance is registered to or unregistered from <br>
> consul</span>,<span lang="EN-US">consul-template will trigger all nginx instances to
<br>
> reload. In a busy system, this happens very frequently, and each <br>
> reload will cause many "keepalived" connections to be closed. <br>
> The client based on golang got a lot of "server closed idle <br>
> connection" and "EOF" errors.<br>
<br>
The "server closed idle connection" doesn't look like an error at <br>
all. Not sure what "EOF" means, but either way it looks more like <br>
an issue in the client than something to address in nginx.<br>
<br>
> Of course, the client should implement the "auto retry" logic, <br>
> but I think we have a better way to completely solve this <br>
> problem in nginx. My idea is, don't treat the keepalived http <br>
> connections as idle connections, and send a "Connection: close" <br>
> header in the next response. If no more requests come, the <br>
> worker process will wait until "keepalive_timeout", then exit, <br>
> and won't wait long. So, if we give the client a smaller <br>
> "IdleConnTimeout", there is no race now. If someone doesn't want <br>
> to use this patch, just leave "keepalive_graceful_close" unset.<br>
<br>
To re-iterate: even with your patch (which basically returns the <br>
nginx behaviour before 0.5.15), the race is still here, since <br>
there are cases when keepalive connections are closed (notably, <br>
when keepalive_timeout expires, or when there are no free <br>
connections). That is, the patch basically tries to hide client <br>
issues in some common case at the cost of keeping old worker <br>
processes alive till keepalive_timeout expiration. Still, these <br>
issues can re-appear in other cases, and the only complete <br>
solution can be implemented on the client.<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-devel mailing list<br>
nginx-devel@nginx.org<br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
</div>
</body>
</html>