title: Increasing max outbound connections on CentOS
body: <p>I learned from this articl: <a href="https://mrotaru.wordpress.com/2013/10/10/scaling-to-12-million-concurrent-connections-how-migratorydata-did-it/" rel="noreferrer">Scaling to 12 Million Concurrent Connections: How MigratoryData Did It</a> that it's possible to make more than 64K connections from a single client with multiple IP.</p>
  
  <p>Now I have an AWS ec2 machine that has 10 IPs for testing. The config in /etc/sysctl.conf is</p>
  
  <pre><code>fs.nr_open = 2000000
  fs.file-max = 2000000
  </code></pre>
  
  <p>And the config in /etc/security/limits.d/def.conf is</p>
  
  <pre><code>*       soft    nofile  2000000
  *       hard    nofile  2000000
  </code></pre>
  
  <p>I start one process (written in C) and create 60000 connections from the first IP address. Everything works fine.
  Than I started another process and try to create 60000 connections from the second IP address but it gets error when the number of connections reaches about 7500 (total number: 67500). The error message is <code>Connection timed out</code>.</p>
  
  <p>The problem doesn't seem to be file descriptor limitations because I still can open/read/write files in the client machine. But any out going connection to any remote server gets timed out.</p>
  
  <p>The problem is not in the server side because the server can accept many more connection from different client machine.</p>
  
  <p>It looks like there's some kind of settings rather than number of open files that limits the number of outgoing connections. Can anyone help?</p>