I host a MongoDB cluster for users.
To improve the availability of the cluster, there are multiple mongos instances the users can connect to.
With their username, password and port, each user gets a hostname (like "beajhmfbjx0yfuo.mongodb.clvrcld.net").
Originally, we set up the hostname as a CNAME like that:
The problem with that is that the node client queries the DNS every time it wants to perform something across the network. Like a cursor.next().
Basically, I can configure the node client with many addresses to setup many mongos endpoints. But if I give one domain name only and that name resolves to multiple IPs, the node client will resolve that name often and may pick a different IP each time, then execute the cursor.next() on a different mongos instance than before… and get an error.
Can you either recognize the roundrobin DNS and setup the different IPs as as many endpoints, or run DNS queries once and for all when creating a connection?