3

我正在使用和尚模块从 mongodb 获取数据。但是,一旦我连接到 db,它就会创建 5 个连接。

这是我的命令行 mongodb 服务器控制台...

 2015-05-14T10:32:35.618+0530 I NETWORK  [initandlisten] connection accepted from
    127.0.0.1:61015 #3 (2 connections now open)
2015-05-14T10:32:35.619+0530 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:61016 #4 (3 connections now open)
2015-05-14T10:32:35.621+0530 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:61017 #5 (4 connections now open)
2015-05-14T10:32:35.621+0530 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:61018 #6 (5 connections now open)
2015-05-14T10:32:35.622+0530 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:61019 #7 (6 connections now open)
2015-05-14T10:32:35.629+0530 I NETWORK  [conn3] end connection 127.0.0.1:61015 (
5 connections now open)
2015-05-14T10:32:35.629+0530 I NETWORK  [conn4] end connection 127.0.0.1:61016 (
5 connections now open)
2015-05-14T10:32:35.629+0530 I NETWORK  [conn5] end connection 127.0.0.1:61017 (
5 connections now open)
2015-05-14T10:32:35.629+0530 I NETWORK  [conn6] end connection 127.0.0.1:61018 (
5 connections now open)
2015-05-14T10:32:35.629+0530 I NETWORK  [conn7] end connection 127.0.0.1:61019 (
5 connections now open)
4

1 回答 1

0

设置monk连接池大小如下:

const monk = require('monk');
const db = monk('localhost/mydb', {
  poolSize: 7 // number of connections
});

它默认为5.

来源:https ://automattic.github.io/monk/docs/manager/

于 2020-01-13T22:38:22.187 回答