Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is multi tenancy and ways to achive it?

I have been reading about multi-tenancy for quite a while. With the very trivial statements like below. I have read dozens of links and sites but all are quite abstract.

..In which a single instance of software runs on a server and serves multiple tenants.

I was quite comfortable in understanding it from above 30000ft but I was not able to comprehend the way it can be implemented.

If anyone can please help me understand with a single stack(just technical) and with an example(may be Salesforce) how do I achieve it and, I would be more satisfied because I am in desperation to know it since almost few days.

Kindly do not post links of Wikipedia or any websites. I have read most of them and yet hunt is on!

I understand this is a very trivial question yet please do not down vote for very few good reasons as you may read some new answers out of this question!

like image 284
chaosguru Avatar asked Jan 03 '23 23:01

chaosguru


1 Answers

With multitenancy multiple installations can be served by one and the same application. Let's say you have an application for organizing the stock of products that a customer has and you are selling it to two different customers: tenant1 and tenant2. With multitenancy your application can run somewhere on a single server and still be accessed by both of your customers.

The goal is to separate the data so that tenant1 is not aware of tenant2. Typically multitenancy can be achieved on database level. You have the following options:

  1. The data is stored in the same table but the separation happens in an extra column (a so called discriminator column):

    SELECT * FROM products WHERE tenant_id = 1;
    
  2. The data is stored on the same database server but in different schemas. Before the application fetches the results it needs to select the appropriate schema:

    USE tenant_1;
    SELECT * FROM products;
    
  3. The data is stored on different database servers. For each tenant a connection pool needs to be kept.

like image 78
FarwoodHill Avatar answered Mar 08 '23 11:03

FarwoodHill