title: haproxy ulimit-n computation
body: <p>I got a <a href="https://github.com/docker-library/haproxy/blob/feefabf1ea0f03879f9d529dcc5b8ec6f3112bba/1.8/alpine/Dockerfile" rel="nofollow noreferrer">haproxy 1.8 vanilla alpine docker image</a> running with <code>maxconn = 2000</code></p>
  
  <pre><code>curl -s http://host:port/stats| grep maxsock
  &lt;b&gt;maxsock = &lt;/b&gt; 4017; &lt;b&gt;maxconn = &lt;/b&gt; 2000; &lt;b&gt;maxpipes = &lt;/b&gt; 0&lt;br&gt;
  </code></pre>
  
  <p>Sometimes I get the following Warning in my logs:</p>
  
  <pre><code>[WARNING] 0/0 (0) : [/usr/local/sbin/haproxy.main()] FD limit (4015) too low for maxconn=2000/maxsock=4016. Please raise 'ulimit-n' to 4016 or more to avoid any trouble.
  </code></pre>
  
  <p>I find it very odd since I read this in <a href="https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#ulimit-n" rel="nofollow noreferrer">haproxy doc</a>:</p>
  
  <blockquote>
    <p>ulimit-n  
    Sets the maximum number of per-process file-descriptors to . By
    default, it is automatically computed, so it is recommended not to use this
    option.</p>
  </blockquote>
  
  <p>Not sure if it's a bug on haproxy or something I am doing wrong.</p>
  
  <p>What do you think of that?</p>
  
  <p>edit: <code>haproxy</code> is running as <code>root</code></p>