fmchan
fmchan

Reputation: 760

Which Mongo instance in Replica Set is called and When will they be called?

I have a replica set which has three mongod instances (1 primary and 2 secondaries) and I set secondaries readable:

db.getMongo().setSlaveOk()

Therefore, in my understanding, all the instances are possible to be called. However, how may I know which instance is a application calling and when or in which situations will the secondaries be called for a application? Thank you.

Upvotes: 0

Views: 32

Answers (1)

NG.
NG.

Reputation: 22904

Writes in Mongo always get directed to the primary.

In terms of reads, it depends on the Read Preference. Setting slaveOk tells the driver that the current connection should be allowed to read from a secondary, but the read preference still plays a role on what replica is queried.

Upvotes: 1

Related Questions