Mongodb – How to make mongos to be in a replica set

mongodb

I have a shard cluster: one mongos, three shard replica sets and one config replica set. My application only talks to the mongos for read/write to mongodb. I wonder whether I can make the mongos replica. What I mean by this is that in case of a mongos is down, I need a slave of the mongos to become the primary. There is --replSet parameter on mongod but mongos doesn't have such parameter. How can I make it in mongos?

Best Answer

You cannot have mongos as a replica set, it is just "proxy" between application and cluster. You can have multiple mongos-services. Normally you create mongos service to the same machine where you have the application. So, every application node has its own mongos and your application connects to that localhost mongos. If you mongos is down, your (single) application is down already, probably.

Of course, nothing prevents you to create multiple mongos nodes and put load balancer to the front of them. But I wouldn't recommend that.