Short answer
Starting with MongoDB 2.4, mongos servers provide a routing service for direct read and write requests to the corresponding fragments. mongos servers discover the configuration of your shard cluster through configuration servers. You can find more information in the MongoDB documentation: Request Routing with Closed Clusters .
Longer bucket
I am trying to understand how different instances of the mongos server work.
mongos servers do not currently speak directly to each other. They coordinate activity using your configuration servers:
- reading fragment cluster metadata
- initiating a balancing round (any
mongos can start a balancing round , but only one round can be active at a time)
If I have 1 configserver
You should always have 3 configuration servers. If you somehow lose or ruin your configuration server, you will have to merge your data and redraw your databases. The fragment cluster metadata stored on the configuration servers is the ultimate source for fragment data ranges to live on each fragment.
some fragments, for example four, each of which consists of only one node (master, of course)
Ideally, each shard should be supported by a set of replicas if you want optimal uptime. Replica sets provide automatic disaster recovery and can be very useful for administrative purposes (for example, for backing up or adding indexes offline).
Is it possible that one mongo redirects its load to other mongos?
No, mongos do not perform load balancing. A typical recommendation is to deploy one mongos for each application server.
From the point of view of the application / driver, you can specify several mongos in the connection string to recover from failure. Application drivers usually connect to the closest mongos available (by network connection time) and try to connect to it if the current mongos connection fails.
Stennie
source share