Multi-tenancy is core aspect of any SaaS architecture. All SaaS based solutions should ultimately move to multi-tenancy architecture for the business model to work. It is necessary for any SaaS offering to keep their operations overhead to minimum to actually make this financially successful business model.
Multi-tenancy is the ability to host multiple customers data on a single instance while protecting everyone's privacy. Designing Multi-tenancy application is different than designing an application for a single customer. The complexity of the design increases if applications are made highly configurable. Configurability is introduced to make applications customizable for customers to a certain extent.
In this blog, of course we will look into data architecture of a multi-tenant application.
There are three models that can be adopted.
1. Separate Database
2. Shared Database, Separate Schema
3. Shared Schema
Separate Database
Features:
- Each tenant has it's own database
- Data of each tenant is isolated from each other
- Datamodel can be extended
- Data restoration per tenant is easier is case of failure
- Maintenance cost is higher
- May be useful for applications that need to comply with strict data isolation requirements ( Financial or Healthcare )

Shared Database, Separate Schema
Features:
- Each tenant has it's own schema under same database
- Different set of tables for each tenant
- When tenant subscribes to service, the provisioining service can create schema for the tenant
- Data model can be extended as per tenant requirement
- There is some degree of isolation
- Data restoration per tenant is complex in case of failure
- Is feasible for application with less number of tables. As no of tables increases, this approach becomes very complex

Separate Schema
Features:
- All tenants share the same database and same schema
- Each record is associated by a tenant ID
- Cost of maintenance is low
- Code need to be more robust for security so that records are accessed by corresponding tenant
- Data model can be extended as per tenant requirement
- There is no isolation
- Data restoration per tenant is complex in case of failure

0 comments:
Post a Comment