Challenge - 5 Problems
Secondary Read Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Read Preference Impact
In MongoDB, what is a primary trade-off when configuring an application to read from secondary replicas instead of the primary?
Attempts:
2 left
💡 Hint
Think about how data replication timing affects read freshness.
✗ Incorrect
Reading from secondaries can cause the application to see outdated data because secondaries replicate data asynchronously and may lag behind the primary.
❓ query_result
intermediate2:00remaining
Result of Reading from Secondary with Lag
Given a MongoDB replica set where the secondary is 5 seconds behind the primary, what is the expected behavior when a read query is sent with read preference set to 'secondary' immediately after a write on the primary?
MongoDB
db.collection.insertOne({item: 'book', qty: 10});
// Immediately after, a read with readPreference: 'secondary' is performedAttempts:
2 left
💡 Hint
Consider how replication delay affects data visibility on secondaries.
✗ Incorrect
Since the secondary is behind by 5 seconds, it will not have the new document until it replicates the write from the primary, causing a delay in visibility.
❓ optimization
advanced2:00remaining
Optimizing Read Latency with Secondary Reads
Which strategy best reduces read latency when using secondary reads in a geographically distributed MongoDB replica set?
Attempts:
2 left
💡 Hint
Think about how network distance affects latency.
✗ Incorrect
Using 'nearest' read preference allows the application to read from the closest replica, reducing network latency and improving read performance.
🔧 Debug
advanced2:00remaining
Diagnosing Stale Data Reads
An application reads from secondaries but notices stale data frequently. Which MongoDB feature can help reduce stale reads without sacrificing availability?
Attempts:
2 left
💡 Hint
Consider how read concern affects data consistency.
✗ Incorrect
'readConcern: majority' ensures that reads return data that has been acknowledged by a majority of replica set members, reducing stale reads while still allowing reads from secondaries.
🧠 Conceptual
expert2:00remaining
Trade-offs of Reading from Secondaries in High Write Workloads
In a MongoDB replica set with heavy write traffic, what is a key trade-off when enabling reads from secondaries to scale read throughput?
Attempts:
2 left
💡 Hint
Think about how replication lag affects read freshness and system scalability.
✗ Incorrect
Reading from secondaries improves read scalability but can cause applications to see stale data because secondaries lag behind the primary during heavy write loads.