Multitenancy is when several different customers are accessing the same computing resources. For example consider, when several different companies are storing data on the same physical server. Multi-tenancy is an important feature of cloud computing.
What is multi-tenancy?
Multi-tenancy is an architecture in which a single instance of a software or application servers multiple customers. Here each customer is a tenant. Tenants may have the abilities to customize some parts of the application, such as UI color, logo, company name, address etc. But tenant can’t modify the application’s code.
In this architecture multiple instances of an application operate in a shared environment. Each tenant is integrated physically, but separated logically. This types of architecture is used to enable multiple users to use a single application.
Multi-tenant architecture is used most with cloud computing. It is found in both public cloud (such as Amazon Web Services, Microsoft Azure and Google Cloud) and private cloud. Also it is a key part of another cloud model, software as a service (SaaS).
Multi-tenant Database
In multi-tenant architecture database is very important matter. There are three ways we can design our database in multi-tenant system, with different complexity and cost.
Single database, shared schema
In this system one database is used to hold all the tenant’s data. Every tenant’s data is stored in the same table. Each table has a specific column that identify tenant’s row. Select operation is costly, modify schema is easy & low costly.
TenantId | Id | Name |
1 | 1 | John Abrar |
1 | 2 | Mikel Adward |
2 | 3 | Mr. Bell |
Single database, separate schema
In this system one database is used to hold all the tenant’s data. Each tenant data is stored in the separate table.
Id | Name |
1 | John Abrar |
2 | Mikel Adward |
Id | Name |
1 | John Abrar |
2 | Mikel Adward |
Database per tenant
In this system each tenant has their own database.