I've been using MongoDB (3.2.9) replication for years and barely know the detail how it works. My Stack is Rails 4.2.5 with Mongoid 5.1.3. I've 3 database servers, let's call them A (Primary), B (Secondary) & C (Secondary). My Mongoid configuration as follow:
production:
clients:
default:
database: db_production
hosts:
- A:27017
- B:27017
- C:27017
options:
pool_size: 10
timeout: 60
replica_set: my_replset
options:
raise_not_found_error: false
What I thought for years, server A is only for write and B+C for read only operation. But when I check on the doc lately (https://docs.mongodb.com/v3.2/replication/), it show that server A is doing write & read while B & C get the copy from A.
So my questions is: How to make sure if B & C serving a 'read' operation to any request? I'm afraid all the requests hitting the server A while B & C are exists just for backup failover.
thanks for any feedback