搜索

首页  >  问答  >  正文

golang - go连接mongo replica set时,如何让read均匀分布到各个secondary上去?

replicaset有两个secondary,Eventual mode,但在使用labix/mgo.v2连接mongo时,发现所有的read都只集中在一个secondary上了,仅有很少的量会访问另外一个secondary。

// Read preference modes are specific to mgo:
Eventual  Mode = 0 // Same as Nearest, but may change servers between reads.
Monotonic Mode = 1 // Same as SecondaryPreferred before first write. Same as Primary after first write.
Strong    Mode = 2 // Same as Primary.
过去多啦不再A梦过去多啦不再A梦2788 天前920

全部回复(1)我来回复

  • 怪我咯

    怪我咯2017-05-02 09:26:30

    1、检查一下connect URL的设置;

    2、如果读的Load Balance和你设置的参数的预期不一样,可以考虑配合设置Tag,进一步配置从什么member读。

    供参考。

    Love MongoDB! Have Fun!

    回复
    0
  • 取消回复