Read Preference mode for MONGO
MONGO query process, the default is the primary mode, that is, from the Master node query. There are other patterns, of course. A bit of the main mode is that you can always read the latest data, the disadvantage is that the read and write at the same node, the load is relatively high.
MONGO several modes of query,
Primary: By default, all are read from Primary's replica set
Primarypreferred: In most cases read from Primary's replica set, when it is not available, from its secondary members
Secondary: All read operations are read from secondary member
Secondarypreferred: Read from secondary member in most cases, when secondary member is not available, read from primary
Nearest: read from replica set with minimum network delay
It is important to note that the configuration is still in effect when read preference is connected through MONGOs.
process of Read preference
Member Selection (memberselection)
The driver and MONGOs of the client periodically update the state of the replica set
If you select Read preference for non-primary mode, then client driver determines which member to connect in the following way: The type of member (Primary,secondary,or all Members) collect a series of suitable member if the tag set is specified, then the member that do not match the tag set are excluded by absolute value which member is the closest distance to the client by the specified distance (ping time, The default is 15ms), you can find a series of members located within this distance, which can be defined as absolute nearest from the series of member selected randomly.