[PATCH] Fix drain logic for small number of connections
mdounin at mdounin.ru
Sat Dec 31 02:04:14 UTC 2016
On Fri, Dec 30, 2016 at 12:13:01PM -0600, Joel Cunningham wrote:
> > On Dec 29, 2016, at 1:13 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> > I agree though that if connection shortage is occasional the
> > current behaviour might not be optimal with worker_connections set
> > to a small value, or there are only a few connections can be
> > reused. Instead of gradually reducing keepalive (and post accept)
> > timeout to a smaller value it closes all keepalive connections
> > from time to time.
> > Probably optimal solution would be to close no more than some
> > fraction of reusable connections at once. Patch series below.
> I tested out the patch series and I did run into a problem.
> Looks like the reusable_connections_n increment and decrement
> are swapped. The first call to ngx_reusable_connection causes
> unsigned integer wrap around. I swapped the increment/decrement
> and the patch gives the expected behavior of only freeing 1/8
> (or at least 1) of the reusable connections.
Thanks for noticing this, fixed.
More information about the nginx-devel