What is multi tenancy and ways to achive it?
Asked Answered
S

2

5

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!

Studbook answered 5/1, 2018 at 16:34 Comment(1)
This is how Salesforce does it: Platform Multitenant Architecture | Salesforce ArchitectsSpillway
B
7

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.

Bohemian answered 12/1, 2018 at 15:20 Comment(0)
L
4

It is simply the idea that you have multiple customers using the same application. Most websites are multi-tenant. They have multiple customers using the same installation. This means you have to do things like restrict views so that the customer only sees the records that belong to his/her organization.

It is usually implemented by putting things like a customer ID in all the tables, and making sure queries are always filtered by that customer ID.

Limber answered 5/1, 2018 at 16:46 Comment(2)
Thats sounds more monolithic of design AFAICT! and also very abstract! anything more precise and concrete?Studbook
It doesn't have anything to do with being a monolith... That's an orthogonal concern. You would have to give a LOT more details about your particular problem space for me to be able to give you something more concrete.Limber

© 2022 - 2024 — McMap. All rights reserved.