I have configured Config servers as a replica set of 5 members. So, now to interact with the Config servers replica set, I am running 3 routers from three different machines, and the configuration of the routers looks something like below
systemLog: destination: file path: /opt/logs/mongodb/router.log logAppend: true net: port: 27017 bindIp: localhost,x.x.x.91,127.0.0.1 sharding: configDB: cfrs/x.x.x.1:27019,x.x.x.2:27019,x.x.x.3:27019,x.x.x.4:27019,x.x.x.5:27019 security: keyFile: /opt/certs/mongodb/keyfile
Now my spring boot application interacts with these routers. Since mongos tracks what data is on which shard by caching the metadata from the config servers, is it possible to configure the mongos to read the metadata about the shards from the nearest Config server?
Also, how to configure the routers to read the data from the nearest shard node i.e. readPreference? Though I am setting the readPreference from Spring boot using MongoDB driver, I am not sure whether this readPreference is applicable when reading data from the Shard replica set or from the Config servers replica set?
Thanks in advance