golang - go连接mongo replica set时,如何让read均匀分布到各个secondary上去?
过去多啦不再A梦
过去多啦不再A梦 2017-05-02 09:24:30
0
1
824

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梦

reply all(1)
刘奇

1. Check the connect URL settings;

2. If the Load Balance read is different from the expectations of the parameters you set, you can consider setting the Tag to further configure which member to read from.

For reference.

Love MongoDB! Have Fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!