搜尋

首頁  >  問答  >  主體

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梦2757 天前892

全部回覆(1)我來回復

  • 怪我咯

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

    1、檢查一下connect URL的設定;

    2、如果讀取的Load Balance和你設定的參數的預期不一樣,可以考慮配合設定Tag,進一步配置從什麼member讀。

    供參考。

    Love MongoDB! Have Fun!

    回覆
    0
  • 取消回覆