Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Multi-Tenancy with Multiple Databases

I can't seem to find any updated resource/guide, plugin or example about Grails Multitenancy with Multiple Databases (one per tenant). I'm currently stuck with https://grails.org/plugin/multi-tenant-single-db and the outdated https://grails.org/plugin/multi-tenant-core.

How to perform database switching that depends on the logged-in user?

like image 352
renz Avatar asked Oct 19 '22 03:10

renz


1 Answers

Grails abstracts out a lot of Hibernate stuff so there is an impedance mismatch between Gorm and Hibernate. One such problem is loading of multiple datasources based on tenant. If you go tenant per DB strategy, be prepared for a hard battle. Apart from complexity involved, there is a long way going forward as DB maintenance is quite costly in this strategy. Most modern applications use Single DB Single Schema approach and I've also used this approach in my plugin. Currently this plugin resolves tenant using Spring Security. The reason for this approach was the application I was working on which was a SaaS app to be served from a single domain. If you have to serve from multiple domains, there is minor modification required in this plugin.

Regarding migration to grails3,it was released in March 2015 and over the period of one year, it has gone through various improvements and bug fixes. It is stable enough to rely on and moreover it has almost all necessary plugins already ported. If you are building a new application, you must go the grails3 way. If you have an existing application, you can consider migrating to grails3.

like image 104
Ejaz Ahmed Avatar answered Oct 22 '22 00:10

Ejaz Ahmed