【发布时间】:2018-08-08 09:32:33
【问题描述】:
我在 NodeJS 和 MySQL 中使用连接池。在睡眠状态的进程列表中还有几个连接,即使站点没有大流量,最终也会导致连接过多。
这是我使用的示例代码:
var pool = mysql.createPool({
host: '127.0.0.1',
user: '***',
password: '***',
database: '****'
});
pool.getConnection(function (err, connection) {
connection.query("SELECT * from test", function (error, data) {
connection.release();
if (error) {
console.log(error);
} else {
// perform further process
}
});
});
连接没有在适当的位置释放?建议上面的代码是否有任何改进。
【问题讨论】:
-
还是没有找到解决办法!!!
标签: mysql node.js database-connection connection-pooling