March 2019
Intermediate to advanced
394 pages
11h 4m
English
By default, all writes and reads go/come from the primary server. Secondary servers replicate data, but are not used for querying.
In some cases, it may be beneficial to change this and start to take reads from secondaries.
The MongoDB official drivers support five levels of read preference:
|
Read Preference Mode |
Description |
|
primary |
This is the default mode, where reads come from the primary server of the replica set. |
|
primaryPreferred |
With this mode, applications will read from the primary, unless it is unavailable, in which case reads will come from secondary members. |
|
secondary |
Reads come exclusively from secondary servers. |
|
secondaryPreferred |
With this mode, applications will read from secondary ... |
Read now
Unlock full access