title: Architecture needed to reduce mysql connections in AJAX/PHP/MYSQL
body: <p>BACKGROUND:</p>
  
  <p>I am passing variables through AJAX to php file. The php file connects to a server and retrieves the result which it passes back to javascript. This happens every time a user clicks on the request button (about every 5 secs). Thus for each user, the php file (and so the mysql connection) is called once every 5 secs.</p>
  
  <p>ISSUE:</p>
  
  <p>As is apparent above, the number of mysql connections are impractically high. </p>
  
  <p>QUESTION:</p>
  
  <p>Is there a better architecture where instead of having so many mysql connections, I can rather have fewer connections. </p>
  
  <p><img src="https://i.stack.imgur.com/VToyP.jpg" alt="enter image description here"></p>
  
  <p>I have read a little bit about mysql_pconnect. But what happens if I have to upgrade since I read somewhere that mysqli doesnt support it? How many queries can a single mysql_pconnect handle? If anyone suggests mysql_pconnect then how to implement it?</p>