简体   繁体   English

使用sequelize我是否需要担心node.js的mysql连接池?

[英]do I need to worry about mysql connection pooling for node.js using sequelize?

I'm new to node.js and have heard of connection pooling and it makes sense to me as the connection is an expensive operation. 我是node.js的新手并听说过连接池,这对我来说很有意义,因为连接是一项昂贵的操作。

I am looking at which node module to use for mysql and I like the look of Sequelize as it is an ORM. 我正在寻找用于mysql的节点模块,我喜欢Sequelize的外观,因为它是一个ORM。

I'm not sure if I need to worry about connection pooling with Sequelize. 我不确定是否需要担心与Sequelize的连接池。 Do I just instantiate it and reuse it for all clients? 我只是实例化它并为所有客户重用它吗?

var sequelize = new Sequelize('database', 'username'[, 'password'])

Also, do I need to worry about the number of parallel queries being executed? 另外,我是否需要担心正在执行的并行查询的数量?

For example, if I am looping through a table and executing a query per row. 例如,如果我循环遍历表并执行每行查询。 What happens if there are 1000 or more rows? 如果有1000行或更多行会发生什么?

Do those queries get executed all at once? 这些查询是否一次性执行?

If so, is there a limit to the amount you can throw at it? 如果是这样,你可以投入的金额是否有限制?

at the very moment Sequelize is not using pooling. 在Sequelize没有使用池的那一刻。 This caused many problems in the past, so it was removed. 这在过去造成了许多问题,因此被删除了。 I will add pooling again in later versions of Sequelize. 我将在Sequelize的更高版本中再次添加池。 At the moment, every request opens a new connection. 目前,每个请求都会打开一个新连接。 There is also a known bug, which leads to unclosed connections. 还有一个已知的错误,导致未关闭的连接。 Due to heavy enhancements in the next version, this will hopefully be fixed. 由于下一版本的重大改进,这有望得到修复。 I will also change from the currently used node-mysql to another mysql connector, which is much faster. 我还将从当前使用的node-mysql更改为另一个更快的mysql连接器。 Once this is done, I try to add pooling again. 完成后,我尝试再次添加池。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM