0
0
MongoDBquery~5 mins

Read preference for replica sets in MongoDB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a read preference in MongoDB replica sets?
A read preference tells MongoDB which members of a replica set to read data from. It helps balance load and control data freshness.
Click to reveal answer
beginner
Name the five standard read preference modes in MongoDB.
Primary, PrimaryPreferred, Secondary, SecondaryPreferred, and Nearest.
Click to reveal answer
beginner
What does the 'Primary' read preference mode do?
It directs all read operations to the primary member of the replica set, ensuring the most up-to-date data but no load balancing.
Click to reveal answer
intermediate
How does 'SecondaryPreferred' read preference work?
It reads from secondary members if available, but falls back to primary if no secondary is reachable, balancing freshness and availability.
Click to reveal answer
intermediate
Why might you use the 'Nearest' read preference mode?
To read from the member with the lowest network latency, regardless of whether it is primary or secondary, improving read speed.
Click to reveal answer
Which read preference mode always reads from the primary member?
ASecondaryPreferred
BSecondary
CPrimary
DNearest
If you want to read from a secondary but fall back to primary if no secondary is available, which mode do you choose?
APrimary
BPrimaryPreferred
CNearest
DSecondaryPreferred
What does the 'Nearest' read preference mode prioritize?
AMember with lowest network latency
BPrimary member only
CSecondary members only
DRandom member
Which read preference mode can help distribute read load across secondaries?
ASecondary
BPrimaryPreferred
CPrimary
DNearest
What happens if you use 'PrimaryPreferred' and the primary is down?
AReads fail immediately
BReads go to secondaries
CReads go to nearest member
DReads go to arbiter
Explain the purpose of read preferences in MongoDB replica sets and list the available modes.
Think about balancing data freshness and load distribution.
You got /3 concepts.
    Describe a scenario where using 'SecondaryPreferred' read preference is beneficial.
    Consider read load and data freshness trade-offs.
    You got /3 concepts.