Reputation: 1421
I have read that I must write to one(specifically master) node in MongoDB. Then data replicates to another nodes(slaves). So, question is, how long it takes to replicate data, as I want to read data from cluster(specifically from slaves)? Or should I also read from master node?
Upvotes: 0
Views: 45
Reputation: 66834
You are not guaranteed to get accurate data from secondary nodes. The time taken to synchronise data depends on data size and network performance.
The manual says that reads come from the primary by default:
By default, clients read from the primary; however, clients can specify a read preference to send read operations to secondaries. Asynchronous replication to secondaries means that reads from secondaries may return data that does not reflect the state of the data on the primary.
However, you may want to read from another node for performance reasons. When doing this you will have to accept that the data may not be current, so you need to judge if this is a suitable trade-off for your application.
Upvotes: 2