I've built a Node.js
server that uses the node-mysql
module to connect to a MySQL
server. I use the following piece of code:
var pool = mysql.createPool(
{
connectionLimit : 15,
waitForConnections : true,
host : 'remotehost',
user : 'root',
password : 'pass',
database : 'master',
}
);
This works fine most of the time. However, when I leave the page open for some time (about 30 minutes) and reload it, the time taken for features that require a connection to the database to load is significantly longer. Also, it is only the first connection after the wait that takes a long time to establish. What do you think could be the reason for this?
I use the following syntax to return a connection to the pool after making a query:
connection.query("SELECT * FROM logtable", function (err, rows, fields) {
if (err) throw err;
});
connection.release();