Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql connection design and concurrent connections
    text
    copied!<p>My application will be hosted in a shared hosting provider with a limit of 25 Mysql concurrent connections. Below is my code for connecting to DB</p> <pre><code>function dbConnect() { $dbHost = 'localhost'; $dbUser = 'user'; $dbPass = 'pass'; $dbName = 'dbase'; mysql_connect($dbHost, $dbUser, $dbPass)or die(mysql_error()); mysql_select_db($dbName) or die(mysql_error()); } </code></pre> <p>My application is more on database query. The home page alone has atleast 20 mysq_query in it. The way I code my home page is like below</p> <pre><code>include 'config.php'; dbConnect(); </code></pre> <p>query1 ... //to get initial variables</p> <p>process variables that result in multiple query</p> <p>query2... // process result</p> <p>query3...// process result</p> <p>and so on up to....</p> <p>query 20...// process result</p> <p>I cant minimize the query anymore coz most of the query is prerequisite of the other query. I am expecting of at least 1000 users daily, and the possibility of 50% of the users will connect on the same time or at lest seconds apart. </p> <ol> <li>On the design of connecting to DB will I easily reach the connection limit set?</li> <li>Is php closing the connection right after the query, meaning it closes after the first query, then open on the second and closes again right after, and so on and son, even if I'm not closing the connection myself</li> <li>Is my assumption correct that the above scenario automatically consumed 20 concurrent connections?</li> </ol> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload