简体   繁体   中英

Grails Support to Handle Datasource Failure

I am looking for a solution for automatic database failover in grails application. I have two databases which reside on two different sites connected over WAN. On Site A, we have Database 01 which is primary database for application on the same site on which database resides which is Application 1 while it would be treated as a secondary database for application on other site which is Application 2 and vice versa.

Please refer to the image below for more details:

期望的数据库复制和故障转移设计

So, according to the design described above:

  • Application deployed on Site A should use database at Site A primarily
  • If somehow database at Site A is not accessible, then application deployed at Site A should use database at Site B (as a secondary database)
  • Once Database at Site A comes up, the application deployed at Site A should again start using the database at Site A (as a primary database)

In the same way, it should work for application at Site B. For application at Site B, Database at Site B should be used primarily (as a primary database) and database at site B (as a secondary database).

Note: When database at corresponding site comes up, application at that site (on which it is deployed) again should start using the database to avoid unnecessary communication over the WAN.

Do grails provide any such support that we may specify two data sources one as a primary and another one as a secondary (that would just be used in case primary isn't accessible.)?

And If there is no such mechanism, then we need to continually check if the primary data source is up & running otherwise switch to the secondary data source which seems inappropriate at all and don't want to go for this option.

The real answer is not to have your code of any sort handle this, but to implement a load balancer which will route traffic accordingly. While you could do this in your own code (in theory), whatever solution you come up with will fall far short of what an actual load balancer is capable of regarding fail overs.

To answer your question, Grails does not have anything that will address this concern. This concern should be addressed outside of your application and instead be part of your network/infrastructure topology design/implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM