I'm working with MySQL more and ran into a question I can't seem to find an answer for without experimenting myself or looking much deeper.
I create a pool with MySQL and release properly, but I see the that there's an active connection still through MySQL Workbench till process is closed. Code example below:
pool.getConnection((err, connection) => {
if (err) {
console.log(err);
return callback(err);
}
if (args.length > 2) {
sql_args = args[1];
}
connection.query(args[0], sql_args, (err, results) => {
connection.release();
if (err) {
console.log(err);
return callback(err);
}
callback(null, results);
});
});
Is this normal behavior for the connection to remain open and if so, what happens if I had hundred servers connecting to this pool and all of them make a request but not all at once, and hit the max-connection limit with MySQL; Will there be a purge of inactive connections (not being used)?
edit I'd wonder if the connections don't close would running a shorter TTL be ideal or some type of clearing? I'd like to have 100 servers fit in a 50 max connection and not error out.