<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">So i'm guessing i might have run into a bug with nginx while i was perf testing one of my applications. Hope i'm wrong and you guys have a solution for me!
<span>😊</span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Set up : <br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">1 Nginx instance running as a tcp load balancer with streams enabled (i have attached the config output with this mail).
</p>
<p style="margin-top:0;margin-bottom:0">4 backend instances running the application</p>
<p style="margin-top:0;margin-bottom:0">1 locust instance to simulate load (tcp requests)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Behavior : <br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">When load is pumped in to the nginx load balancer, the requests are evenly distributed between the backend app instances. When the nginx configuration is modified to remove one instance and nginx is restarted, the new
 config takes effect. A new nginx worker process is spawned and the older one goes into "<span style="color: black; font-family: 'Consolas', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important;">nginx: worker process is shutting down</span>"
 mode. However, we see that on the node that was removed from the list of backend instances in the nginx config, the requests still keep coming in for quite a while (~10secs-2mins depending on the load). Point to note here is that the application processes
 every request within 10-20ms and terminates the tcp connection.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">In essence, the worker process that is scheduled to die still keeps getting new requests, when ideally all new requests should go to the new worker thread.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Please let me know if this is expected behavior or not. If it is, how do i ensure the worker thread that is scheduled to die will get no new requests?</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks,</p>
<p style="margin-top:0;margin-bottom:0">Sagar.<br>
</p>
</div>
</body>
</html>