0
0
MongoDBquery~20 mins

Read preference for replica sets in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Replica Set Read Preference Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Which read preference returns data only from the primary?
In MongoDB replica sets, which read preference ensures that all read operations return data only from the primary node?
Asecondary
BsecondaryPreferred
Cprimary
Dnearest
Attempts:
2 left
💡 Hint
Think about which node is the main source of truth in a replica set.
query_result
intermediate
2:00remaining
What is the output of this read preference setting?
Given the MongoDB read preference set to 'secondaryPreferred', where will the read operations be directed if a secondary is available?
AReads go to a secondary node if available, otherwise to the primary.
BReads go only to the nearest node regardless of type.
CReads go only to the primary node.
DReads go only to secondary nodes and never to primary.
Attempts:
2 left
💡 Hint
Consider the fallback behavior of 'secondaryPreferred'.
🧠 Conceptual
advanced
2:00remaining
Which read preference minimizes read latency by choosing the closest node?
In a MongoDB replica set, which read preference directs read operations to the node with the lowest network latency, regardless of whether it is primary or secondary?
Anearest
Bprimary
CprimaryPreferred
Dsecondary
Attempts:
2 left
💡 Hint
Think about the read preference that considers network distance.
📝 Syntax
advanced
2:00remaining
Identify the correct syntax to set read preference to 'secondary' in a MongoDB connection string
Which of the following MongoDB connection strings correctly sets the read preference to 'secondary'?
Amongodb://host1,host2/?read_preference=secondary
Bmongodb://host1,host2/?readPreference=secondary
Cmongodb://host1,host2/?readPreference=Secondary
Dmongodb://host1,host2/?readPreferenceSecondary
Attempts:
2 left
💡 Hint
Check the exact parameter name and case sensitivity.
optimization
expert
3:00remaining
Optimizing read preference for a geographically distributed replica set
You have a MongoDB replica set with nodes in three different continents. You want to minimize read latency for users worldwide while ensuring strong consistency when necessary. Which read preference strategy should you use?
AUse 'secondary' only to avoid primary node load, ignoring consistency.
BUse 'secondaryPreferred' for all operations to balance load evenly.
CAlways use 'primary' to ensure strong consistency, ignoring latency.
DUse 'nearest' for reads to minimize latency, and 'primary' for writes to ensure consistency.
Attempts:
2 left
💡 Hint
Consider balancing latency and consistency requirements.