Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MultiTenant versus Multiple DBs

I am developing a custom CRM solution which will be sold via the Web/SaaS model. I anticipate tens or hundreds of clients using this solution. I will be using MS SQL as the db engine.

Option 1 is to have a single DB, and include a TenantId column on tables, a suitable index and use 'where tenantId={...}' on each db access.

Option 2 is to have an individual DB for each client, avoiding the need for the TenantId and where clauses.

I anticipate that each client will have hundreds of thousands of records, not millions.

As I see it, there will be a total number of data pages whichever option I go for. The decision seems centered on whether SQL is better at managing multiple DBs, or a single DB with TenantId and index. Initially the solution will run on a single DB server, but will eventually move to SAN.

Does anyone have any views on this?

like image 657
DEH Avatar asked Jun 24 '10 08:06

DEH


People also ask

What is multi-tenant DB?

Multi-Tenantancy – Multi-tenancy means that a single instance of the software and its supporting infrastructure serves multiple customers. Each customer shares the software application and also shares a single database. Each tenant's data is isolated and remains invisible to other tenants.

What is multi-tenant and multi instance?

Multi-tenant and multi-instance are two different types of cloud architecture that determine how and where your data is stored when using software as a service or integration platform as a service – whether a shared or isolated database.

What is multi-tenancy cloud?

A multi-tenant cloud is a cloud computing architecture that allows customers to share computing resources in a public or private cloud. Each tenant's data is isolated and remains invisible to other tenants. In a multi-tenant cloud system, users have individualized space for storing their projects and data.

Which is better single-tenant or multi-tenant?

The architecture has become an industry standard for enterprise SaaS environments. In comparison to single-tenancy, multi-tenancy is cheaper, has efficient resource usage, has a lower maintenance cost and a potentially larger computing capacity.


1 Answers

There is an interesting MSDN article, titled Multi-Tenant Data Architecture, which you may want to check out. The authors make a brief analysis on where a certain approach might be more appropriate than another:

The number, nature, and needs of the tenants you expect to serve all affect your data architecture decision in different ways. Some of the following questions may bias you toward a more isolated approach, while others may bias you toward a more shared approach.

  • How many prospective tenants do you expect to target? You may be nowhere near being able to estimate prospective use with authority, but think in terms of orders of magnitude: are you building an application for hundreds of tenants? Thousands? Tens of thousands? More? The larger you expect your tenant base to be, the more likely you will want to consider a more shared approach.

  • How much storage space do you expect the average tenant's data to occupy? If you expect some or all tenants to store very large amounts of data, the separate-database approach is probably best. (Indeed, data storage requirements may force you to adopt a separate-database model anyway. If so, it will be much easier to design the application that way from the beginning than to move to a separate-database approach later on.)

  • How many concurrent end users do you expect the average tenant to support? The larger the number, the more appropriate a more isolated approach will be to meet end-user requirements.

  • Do you expect to offer any per-tenant value-added services, such as per-tenant backup and restore capability? Such services are easier to offer through a more isolated approach.

Note that the "shared approach" is option 1, and the "isolated approach" is option 2, in your case. You are not biased on either side when it comes to the first two points, so I think I would base my decision on the last two points.

like image 130
Daniel Vassallo Avatar answered Oct 18 '22 12:10

Daniel Vassallo