0
votes

I have to develop a multi tenant SaaS application in j2ee with implementing the three cloud models starting from the Iaas and PaaS,i chose openstack with openshift origin. the first criteria for a SaaS application is multi-tenancy ,i know that there are 3 approaches to achieve it - Separate Databases - Shared Database, Separate Schemas - Shared Database, Shared Schema i get lost here because many frameworks like ATHENA, ORM like hibernate and there is also TOPLINK.I need help to know the best approach to implement a multi tenant java application.

1

1 Answers

1
votes

I like the shared database shared schema approach - which in broad terms means every table has an org_id column and every query is run with the current user org_id as filter.

I like that way because you can shard the database balancing huge tenants with smaller tenants instead of having a custom scale according to each tenant size

I would skip altogether an ORM, too easy to mess things up in a multitenant deployment, and go with an MyBatis solution which allow queries to be verified and reviewed as they are all centralized in few places instead of all over the code.

if you really need a ORM, I know Hibernate comes with its own support but I don't like when libraries force me on a specific data structure, as it takes away flexibility. Just make sure that the only way to obtain a session automatically add tenancy, too easy to mess things up for devs if that is a manual process.

you can find lot of resource and some cost benefit analysis of different approaches here http://msdn.microsoft.com/en-us/library/aa479086.aspx