<div dir="ltr">Maxim,<div><br></div><div>Out of curiosity I checked some of my servers with "ss -l -t -p | grep nginx | wc -l"</div><div><br></div><div>I'm at 15k at most. Large numbers of worker processes make it relatively easy to hit the ~20k limit it seems.</div><div><br></div><div>With Regards,</div><div>Mathew</div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 5 May 2021 at 01:53, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Fri, Apr 30, 2021 at 11:14:48AM +0200, Charlie Kilo wrote:<br>
<br>
> correction.. if i count with<br>
> ss -l -t |grep http | wc -l<br>
> we have around 58340 listening sockets.. at least on that machine..<br>
<br>
Since "listen ... reuseport;" implies a separate listening socket <br>
for each worker process, that's expected with 50 worker processes <br>
and 1200 "listen ... reuseport" in the configuration.<br>
<br>
> On Fri, Apr 30, 2021 at 8:27 AM Charlie Kilo <<a href="mailto:krikkiteer@gmail.com" target="_blank">krikkiteer@gmail.com</a>> wrote:<br>
> <br>
> > Thanks a lot for the hints so far.. to provide the further info and answer<br>
> > the questions..<br>
> ><br>
> > getconf ARG_MAX shows 2097152<br>
> > ulimit -s shows 8192<br>
> > setting it to unlimited, doesn't change anything (also not with prlimit)<br>
> > wc -c /proc/<pid>/environ shows 1949<br>
> ><br>
> > it seems on a regular machine we have around 1200 listening sockets and do indeed use "reuseport"<br>
<br>
Thanks, so all seem to be using the defaults.<br>
<br>
Looking more closely at Linux limits, it seems that you are <br>
hitting the MAX_ARG_STRLEN limit.  It limits single argument <br>
length (and a single environment variable length), and hardcoded <br>
to be 32 pages, that is, almost always 128k.  <br>
<br>
With 128k limit nginx should be able to pass about 20k listening <br>
sockets, so with 58340 sockets you are well above the limit.<br>
<br>
An obvious workaround would be to reduce the amount of listening <br>
sockets - either by dropping the "reuseport", or by reducing the <br>
the number of listening sockets (normally just one on the wildcard <br>
address is enough), or by reducing the number of worker processes.<br>
<br>
It would be interesting to know why you are using such a large <br>
number of listening sockets with reuseport enabled.  If the use <br>
case is reasonable, we probably should consider implementing some <br>
workaround for the 128k limit.<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div>