Load balancing Mongo DB on GCE instance
By default, Click to Deploy MongoDB
GCE sets one primary node, one secondary node and one arbiter node. But I can't figure out how mongodb manages to distribute reads between primary and secondary nodes. I have an explicit one external IP
for every available node, but I don't want to point my apps to one node or the other ... how can I determine the IP address of the load balancer (if there is such a thing) so that I can pass this app as a URL mongodb connection addresses?
source to share
To connect to a MongoDB replica set, you will need to specify all hosts in the standard URI connection scheme. For example, to describe a connection to a named replica set test
with the following mongod hosts:
db1.example.net on port 27017
db2.example.net on port 2500
You must use a connection string that resembles the following:
mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test
For more information on the MongoDB Connection String URI format, see artcile .
source to share