Multi-Tenancy means same instance shared amongst all customers. Each customer is called a Tenant. Customizing of few areas is allowed, but application code changes are not allowed. What is common?
- Operating System
During application design it’s been taken care that information is accessible to correct owner.
Data is key factor for any application. SaaS (Software-as-a-Service) application concept is based on providing centralized access to data to reduce their overheads.
Approachs for Multi-Tenant data:
Totally Isolated or Separate database :
Application code is shared between all Tenants, but every Tenant has its own set of data and it is isolated from data that belongs to other Tenants.
- Restoring data from Backup
- Extending data model
- Fully secured and private
- Higher hardware cost
- Maintenance cost
Partially Shared or Separate schema:
Database is common for all Tenants, but each tenant gets its own Schema. So this is partial separation of data.
- Good for small number of database tables.
- Easy to implement.
- Tenants can add columns or table based on requirement.
- Moderate level of data isolation.
- Resorting of data is tough
- Data is co-located with other tenants
Partitioned (discriminator) data:
In this approach all tenants share common database and schema (Tables). A single instance is shared with multiple tenants and is portioned in such a way that tenants cannot access each other’s information. Tenant Id is used to distinguish data. Extra security efforts are required, so that tenants cannot access each other’s information.
Real world Example:
We have 3 tenants looking for our application, since we are using shared database and schema, a little customization is possible.
Tenant-1: Need same except dress color should be red.
Tenant-2: Need same except flair should be shaded and in different color.
Tenant-3: Needs exactly what is demoed.
- Cost effective: Since resources are shared hardware cost reduces.
- Up gradation is taken care, so no extra efforts required.
- Backup and recovery becomes easy, as all share same database.
- Less customization as everybody is sharing same database and tables.
- Changes can be made without notifying, so no authorization.
Shard means “A piece of broken object”. Database sharding means portioning of database. Each part is known as shard or database shard. Tables are identified which are actually hitting performance and based on that portioning is handled. Data while portioning might appear in multiple shards.
Divided tables will be distributed into multiple servers, this reduces number of rows per table, which reduces index size and helps in performance improvement.
- Easy to manage
- Cost effective
- Complexity of SQL
- Backup becomes difficult
- Full System could fail because of single shard failure
I have keen interest in learning new things, exploring more on a topic and being more versatile