InterviewSolution
| 1. |
Consider sample collection with below entries for a 5-member replica set. |
|
Answer» In MONGODB we can read from Primary as well as secondary members of the replica set. This behaviour can be CONTROLLED by us as we can define the desired Read preference to which clients route read operations to a member of the replica set. If we do not SPECIFY any real preference by default MongoDB will read from primary. There are situations when you would want to reduce the load on your primary by forcing APPLICATIONS to read from secondary. Below are different MongoDB read preference modes:
This is the default mode. Applications read from the replica set primary.
In this mode, all applications read from primary but if the primary member is not available they start reading from secondary.
All applications read from the secondary members of the replica set.
In this mode, all applications read from secondary but if any secondary member is not available they start reading from primary. In this mode, applications read from the member which is nearest to them in terms of network latency, irrespective of the member being primary or secondary. |
|