Node.js MongoDB副本集慢速查询
我已经用6台服务器设置了MongoDB副本集,一切正常,数据被复制,没有问题 当我从node.js直接连接到主服务器时,插入查询的执行时间小于20毫秒,但当我在connection string()中列出所有服务器时,查询的执行时间异常增加,从1.5秒到11秒不等 我使用最新版本的本机mongodb包() MongoDB版本是3.0.10 连接字符串的示例:Node.js MongoDB副本集慢速查询,node.js,mongodb,Node.js,Mongodb,我已经用6台服务器设置了MongoDB副本集,一切正常,数据被复制,没有问题 当我从node.js直接连接到主服务器时,插入查询的执行时间小于20毫秒,但当我在connection string()中列出所有服务器时,查询的执行时间异常增加,从1.5秒到11秒不等 我使用最新版本的本机mongodb包() MongoDB版本是3.0.10 连接字符串的示例: mongodb://s1,s2,s3,s4,s5,s6/my_database?replicaSet=repl 我尝试过各种选项,比如将
mongodb://s1,s2,s3,s4,s5,s6/my_database?replicaSet=repl
我尝试过各种选项,比如将write concern设置为0(即使在副本集配置中设置为1)和journal设置为true,但都不起作用
即使我在连接中只使用2台服务器,字符串执行时间仍然会增加
副本集配置:
{
"_id" : "repl",
"version" : 7,
"members" : [
{
"_id" : 0,
"host" : "mongo1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 2,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 1,
"host" : "mongo2:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 2,
"host" : "mongo3:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 3,
"host" : "mongo4:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 4,
"host" : "mongo5:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
},
{
"_id" : 5,
"host" : "mongo6:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 0.5,
"tags" : {},
"slaveDelay" : 0,
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatTimeoutSecs" : 10,
"getLastErrorModes" : { },
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
}
}
}您有没有可能找到解决方案?我正在经历非常相似的行为