Reputation:
This is the typical way I create MySQL connection in node.js
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'address_book'
});
var app = express();
connection.connect(function(err){
if(!err) {
console.log("Database is connected ... nn");
} else {
console.log("Error connecting database ... nn");
}
});
Is it good enough for production use? When should one use connection pooling? What are the advantages and disadvantages of using connection pooling?
Upvotes: 3
Views: 1038
Reputation: 587
This will work but creating mysql connection for each and every request is not recommended.
So it would be better to have a pool of mysql connections, as cost of getting a connection will be nil compared to prior case.
Upvotes: 1