title: Php - Connection Pooling To Mysql
body: <p>I want to implement connection pooling in Php in a similar way that works in java.</p>
  
  <p>Why I need this :</p>
  
  <p>Let's consider a flow</p>
  
  <pre><code>Step1: Connection To Db --- Resource Id #12
  Step2:  some computation... time taking .3 seconds
  Step3: Query on Solr .... timing taking 2 seconds
  Step4: Connection To Db --- Resource Id #12 (i am using same resource id) 
  Step5: Exit
  </code></pre>
  
  <p>Though in step4 I am using the same DB resource as of step1. However, the connection will go in the sleep state for both step2 and step3 and therefore can't be used by any other PHP process (other clients) until exit.</p>
  
  <p>Solution:</p>
  
  <ol>
  <li><p>use mysql_close every time after query get fired: Drawback: need to connect every time and hence time-consuming</p></li>
  <li><p>Create a java service to handle queries (possible but too time-consuming and I am looking for other solution where I need to migrate queries )</p></li>
  <li><p>Need to explore SQL relay like the third party but I am not sure will that be a success and not  many good companies have used it</p></li>
  <li><p>mysql_pconnect is not solving my case.</p></li>
  </ol>
  
  <p>Please suggest</p>