Solution 1: EPOLLEXCLUSIVE flag
If EPOLLEXCLUSIVE (Linux 4.5, glibc 2.24) is defined when compiling Nginx, Nginx could make use of it to reduce resource usage when volume of new connection is low.
Nginx discards EPOLLRDHUP
if EPOLLEXCLUSIVE
is enabled, keeping EPOLLIN
and EPOLLOUT
compatible with the CentOS 7 backport.
For every 16 requests handled, Nginx would re-add the socket in ngx_reorder_accept_events()
to balance request across workers.
Solution 2: listen reuseport
SO_REUSEPORT could significantly increase the max latency in a degraded state. See https://blog.cloudflare.com/the-sad-state-of-linux-socket-balancing/.
As a side effect, total length of pending connection queue (backlog) is multiplied by the number of workers in this case.