Roh*_*yal 8 mysql connection-pooling node.js
我正在使用nodejs连接池,使用npm的"mysql"模块.在创建池时,我已将connectionLimit指定为100.我想知道在运行时有多少连接在池中使用/未使用.
jfr*_*d00 13
通过查看此处的源代码,您可以看到:
pool.config.connectionLimit // passed in max size of the pool
pool._freeConnections.length // number of free connections awaiting use
pool._allConnections.length // number of connections currently created, including ones in use
pool._acquiringConnections.length // number of connections in the process of being acquired
Run Code Online (Sandbox Code Playgroud)
注意:根据需要创建新连接,直到池的最大大小_freeConnections.length为零,但是限制中有更多连接,因此下次.getConnection()调用时,它将创建一个新连接.