search

Home  >  Q&A  >  body text

golang - How to make reads evenly distributed to each secondary when go connects to mongo replica set?

replicaset has two secondary, Eventual mode, but when using labix/mgo.v2 to connect to mongo, it is found that all reads are only concentrated on one secondary, and only a small amount accesses the other 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 days ago919

reply all(1)I'll reply

  • 怪我咯

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

    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!

    reply
    0
  • Cancelreply