[PATCH] Events: closed unused listening fds in worker processes.

Maxim Dounin mdounin at mdounin.ru
Thu Apr 18 13:32:54 UTC 2019


Hello!

On Thu, Apr 18, 2019 at 06:18:09PM +0800, Zexuan Luo wrote:

> When reuseport is enabled in the 'listen ...' directive and a great
> number of worker processes are used, each worker will inherit lots of
> listening fds from the master process.
> In one of our environments, one worker could have 1.5k fds before it
> starts to accept any request. This situation is too scary to the
> system administrator.

Thank you for your patch.

If the problem is how scared your system administrators are, I 
think one of these approaches might be better:

- Avoid configuring things which scare them.  In particular, you 
  may want to avoid using reuseport when using very large number 
  of worker processes and large number of distinct listening sockets.

- Train your system administrators to not be scared in such 
  cases.

Note well that regardless of the number of file descriptors open 
by a particular worker process, corresponding listening sockets 
are open.  Closing this file descriptors might save some slots in 
the process file descriptor table, but that's all.  And that's more 
or less nothing in terms of resources, even with 1.5k file 
descriptors.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list