title: How many connections/s can I expect between PHP and MySQL on separate server?
body: <p>Trying to separate out my LAMP application into two servers, one for php and one for mysql. So far the application connects locally through a file socket and works fine. </p>
  
  <p>I'm worried about the number connections I can establish if it is over the network. I have been testing tcp connections on unix for benchmark purposes and I <strong>know</strong> that you cannot exceed a certain amount of connections per second otherwise it halts due to the lack of resources (be it sockets, or file handles or whatever). <em>I also understand that php does not implement connection pooling so for each page load a new connection over the network must be made. I also looked into pconnect for php and it seems to bring more problems.</em> </p>
  
  <p>I know this is a very very common setup (php+mysql), can anyone provide some typical usage and statistics they get out of their servers? Thanks!</p>
  
  <hr>
  
  <p>The problem is not related to running out of connections allowed my MySQL. The main problem is that unix <strong>cannot</strong> very quickly create and tear down tcp connections. Sockets end up in TIME_WAIT and you have to wait for a period before you free up more sockets to connect again. These two screenshots clearly shows this pattern. MySQL does work up to a certain point and then pauses because the web server ran out of sockets. After certain amount of time passed, the web server was able to make new connections.</p>
  
  <p><a href="http://img35.imageshack.us/img35/3809/picture4k.png" rel="nofollow noreferrer">alt text http://img35.imageshack.us/img35/3809/picture4k.png</a></p>
  
  <p><a href="http://img35.imageshack.us/img35/4580/picture2uyw.png" rel="nofollow noreferrer">alt text http://img35.imageshack.us/img35/4580/picture2uyw.png</a></p>