As SaaS (Software as a service) takes big steps in these days, lots of new methods or rather less used methods are getting more attention. Making an application truly Multi-tenant is one of the key feature in SaaS. In xEvents, we made the application multi-tenant capable in the initial phase of the project to reduce incremental time and cost factor if we converting into multi-tenant based application in the later stage. We had lots of discussions going back and forth to make right design decision for implementing the multi-tenant enabled platform which is more suitable for xEvents application. We thought it is worth to post here on this topic.
Possible Design solution: One of the Key factor while designing the multi-tenant design is the database design. As we will be intent to store all the tenant data in our server and mostly same set of application code will be accessing different tenant data, designing suitable database structure turned out to be a tricky call. In a broad category, we can implement in 3 different ways:
1. Isolated database for each tenant
2. Isolated schema for each tenant
3. Shared schema for all tenants
Though i have stated three different individual type, it is a continuum spectrum. Most of the time we need to choose a mixed approach (for e.g. sharing few tables/schemes across the tenant and also few separate table per tenant). Meaning, choosing the correct type is fully depends on type of application.
(source: http://i.msdn.microsoft.com/dynimg/IC150005.gif )
Few worth noting factors while making the design decision : No. of Tenants, customization required per tenant, Scalability, database size / maintenance cost, No. of users per tenant, data privacy/isolation issues. This article clearly listed the pros and cons with a detailed analysis.
Multi-tenant grails plugin: Once we are clear with the design in our mind and having grails powered by plugins, now we have to pick-up the right plugin and fine-tune the configuration as per the our requirement. Multi-tenant plugin provides out of box implementation for multi tenant based applications. Though, this is not clearly (rather fully) documented, this page will give you a very good idea to start with and about how this plugin works. Here is our few cents:
1. Although, this plugin suppose single database per tenant, it is little immature as of now[June,2011].
2. There is another version of this plugin (using Hawk Eventing and Hibernate Hijacker) to support single db per tenant. But this is still in the experiment mode.
3. This plugin have incompatibility issue with searchable plugin. we tried few suggestions given in forums to fix this issue, but in vain. (Though, i am not sure of the fact, but this might be because both the plugins modify the datasouce in the beginning or because of the subscription to the hibernate events).
4. Need to be careful about having common pages like admin page which will access data across the tenant. It is not available out of box from this plugin.