title: Maximum number of TCP connections on Ubuntu
body: <p>I'm developing a java server on AWS virtual machines (ubuntu) which will be used for an online android game. I have done a test that showed me maximum ~4080 client can connect to the server. I get the "SocketException : too many files open", if more clients want to connect. I checked the number of limits: "ulimit -n" gives me 1024. Changing it to the 4096 didn't make change.</p>
  
  <p>A new thread is created for any accepted socket and they do nothing currently and are alive until I stop the server.</p>
  
  <p>After all 4080 connections are established, I observe that about 1gb of ram is used. I have total of 2gb.</p>
  
  <p>How can we handle more tcp connections? Is my multithread approach useful or I should follow a different approach for thousands of clients?</p>