Reputation: 969
I am in a process of setting up Sharded cluster.
I also wanted to configure read replicas in cluster.
Suppose there is a Shard of 3, 1 Primary and 2 Secondary. The writes will goto Primary member of a Shard, but can I send all reads to Secondaries?
Upvotes: 0
Views: 280
Reputation: 3760
It is not recommended to read from secondaries in a sharded cluster. This is because unlike the primaries, the secondaries have no idea what data the shard is supposed to contain. So when chunks are migrated from one shard to another, reading from the secondaries might result in duplicate or missing results.
In general, reading from secondaries also means the loss of consistency guarantees, since as long as writes have not propagated from the primaries, the secondaries will see, and return, stale data.
Finally, you should keep in mind that secondaries receive essentially the same write load as the primaries, so reading from the secondaries is not likely to provide much of a performance advantage.
The recommended way to get more read throughput is usually to add more shards, not reading from secondaries.
Upvotes: 3