title: Maxing out MongoDB connections
body: <p>I have this very specific situation where I need one machine to serve a large number of MongoDB databases (such as 10k+) and every user should be able to connect to it directly.
  Our machine is quite powerful and it was running OK for a while, until a few days, when it started causing some problems.</p>
  
  <p>At some point users can't login anymore and I get this from mongoS logs:</p>
  
  <pre><code>2016-08-19T18:08:16.667+0000 I NETWORK  [mongosMain] pthread_create failed: errno:11 Resource temporarily unavailable
  </code></pre>
  
  <p>I've tried to change most parameters MongoDB wise and SO wise, but no luck:</p>
  
  <pre><code>net.netfilter.nf_conntrack_max is 524288
  fs.file-max is 128000
  kernel.pid_max is 288000
  </code></pre>
  
  <p>/etc/security/limits.d/90-nproc.conf has:
      * soft nproc 128000
      * hard nproc 128000</p>
  
  <p>/etc/init/mongos.conf has:</p>
  
  <pre><code>limit fsize unlimited unlimited
  limit cpu unlimited unlimited
  limit as unlimited unlimited
  limit nofile 512000 512000
  limit rss unlimited unlimited
  limit nproc unlimited unlimited
  limit memlock unlimited unlimited
  </code></pre>
  
  <p>but still no luck.</p>
  
  <p>Is there any way for me to handle like 100K+ connections?</p>
  
  <p>Thank you in advance.</p>