MongoDB Load Balancer for Replica Set
2 answers
You don't need to use a load balancer or redirect requests to secondary nodes; the primary node can handle concurrent requests on its own:
- MongoDB supports concurrent requests, both read and write, using a granular locking system
- It is not recommended to use secondary resources to provide additional read capacity as the replication design makes this inefficient and unreliable for most use cases
- If your main resource is taking a long time serving one request in such a way that it blocks other requests, this should be fixed by redesigning the inefficient request or adding appropriate indexes .
- If your server is trying to serve multiple users despite optimizing queries, see if there is not enough hardware to run.
- If you still find that you need to scale your reads and writes, the recommended way to do this is by sharding rather than using other nodes in the replica set.
+6
source to share
Typically, writes are processed by the master, and reads must be sent to secondary users with a read preference. Although it may take some time to get the data propagated to the secondary users, the secondary users use the oplog copy to replicate the data.
You don't need a load balancer, Mongo is capable of that. Read more about this here -
0
source to share