I was wondering if anyone had some tips/guidelines for scaling Nginx on
Linux to >500k concurrent connections. Playing with the
nginx_http_push_stream module in streaming mode. Noticing periodic slow
accept and/or response headers. I’ve scoured the Internet
looking/learning ways to tune Nginx/Linux but I think I’ve exhausted my
abilities.
After a bit more digging I discovered that Nginx sets the backlog on the
listen socket to only 511 (at least on Linux), not the -1 in the docs.
By increasing that to a much larger number I haven’t noticed slow
accepts/response headers. Also for reference, backlog on a listen
socket is silently limited to net.core.somaxconn (which defaults to
128) so make sure to increase that and other necessary tunings as well.