Multi-tenant SaaS Architecture
So, what exactly is a SaaS?
It is a delivery model for software, where software are consumed by a single or multiple entities over internet.It is considered as a form of Cloud Computing A.K.A on demand software and licensing for such kind of software are based on subscription model.
So, Instead of buying and deploying software on your own server and then maintaining it yourself, you simply rent it.
The basics.
To better understand the multi-tenancy, i would use a real world analogy of multi-tenant office building, where if the building has 10 floors and each floor is rented by different organisation (tenant) then each tenant within a building share the same infrastructure utilities such as electricity and water and make use of the common facilities.
How about Multi-tenancy in Cloud Computing?
The same approach can be applied to a single instance of software running on cloud which is serving multiple tenants.So, all tenants share the same platform and infrastructure yet their data is separated from each other.This would be same in the multi-tenant office building analogy that a Tenant-1 do not have the access to Tenant-2 floor and vice versa.
what is the point of using multi-tenant architecture?
If you are creating an app which you are expecting to be used by a lot of companies based on what you are going to provide in the app itself.You could just create a single instance of an app and keep on replicating it for each customer who is willing to use it.
So, is it a correct approach? NO!
But why not this Approach?
Image you are already having 500 customers where each customer is having its own instance of app running separately and out of no where the QA engineer in your company found out a very critical bug in production.Would you expect developers to fix on 500 app instances? The problem would be faced again when the app has a new feature to deploy.
This is where multi-tenant architecture come into action to solve such issues.
And how does it solve?
I would be discussing the single shared database model only.This model is normally adopt by the early stage SaaS startups where the single instance of app is deployed to a cloud and all the tenants would be accessing it, at the same time the data of all tenants are stored in a single database and same tables. The retrieval of data for each tenant will be based on TenantID.