MongoDB load balancing and failover of query routers

本秂侑毒 提交于 2019-12-03 21:37:51

Everyone says it's not relevant and I don't think so.

And your right so. Failover of mongos instances is very important, without proper architecture to deal with this you could have a serious failure in your app. It also breaks the high availability of MongoDB.

What happens if the query router dies?

This is where you should really be putting in a seed list into the connection string in your driver, in this case the driver will do something along the lines of what it does with replicas and try and connect to other members on the list to resume as normal.

Is there an intended way for automatic failover to a second query router?

Provided you supply more mongos instance IPs to your applications configuration this should be pretty automated.

Or for load balancing between 2 query routers?

You can go that route as well if you want a only supply a single IP, but then you have to worry about that load balancer, and so on, and so forth...

There are some drivers (i am sure in JAVA and Python) which supports automatic failover and reconnection if you provide an appropriate list of mongos processes for them. In the JAVA driver also some roundrobin balancing built in, but these features not exists in all drivers. for example C++ driver do not have either. Check for the functionality of the given driver you plan to use.

If you have a balanced application tier above the database, you can place one mongos on each application server and use it dedicated for that. In this case failure of a single mongos will affect only that application server, and ofcourse this will be out while mongos not functioning. This architecture resolves the balancing and the HA issue at once.

Oherway you can use for example HAProxy for loadbalancing in front of mongos processes, but there is no HA functionality built in the mongos processes themselfs so if one go out it will affect all of your API servers with this architecture.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!