Challenge - 5 Problems
Replica Set Read Preference Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2: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?
Attempts:
2 left
💡 Hint
Think about which node is the main source of truth in a replica set.
✗ Incorrect
The 'primary' read preference directs all reads to the primary node, which is the main writable node in a replica set.
❓ query_result
intermediate2: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?
Attempts:
2 left
💡 Hint
Consider the fallback behavior of 'secondaryPreferred'.
✗ Incorrect
'secondaryPreferred' tries to read from a secondary but falls back to primary if no secondary is available.
🧠 Conceptual
advanced2: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?
Attempts:
2 left
💡 Hint
Think about the read preference that considers network distance.
✗ Incorrect
The 'nearest' read preference sends reads to the node with the lowest network latency, whether primary or secondary.
📝 Syntax
advanced2: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'?
Attempts:
2 left
💡 Hint
Check the exact parameter name and case sensitivity.
✗ Incorrect
The correct parameter is 'readPreference' with exact casing and the value 'secondary' in lowercase.
❓ optimization
expert3: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?
Attempts:
2 left
💡 Hint
Consider balancing latency and consistency requirements.
✗ Incorrect
Using 'nearest' for reads reduces latency by reading from the closest node, while writes go to the primary to maintain strong consistency.