How to work with multi tenancy architecture?

I was asked to develop an application with multi tenancy architecture in PHP using MySQL as a database.

After reading several materials and posts on the internet, a question arose. How to model the application itself?

I have two options, they are:

  • shared application and database
    in this case, it would have only one instance of the application and the database for all client.
  • shared application and isolated databases
    in this case, you would have only one instance of the application and each client would have its own database isolated.

The application will serve companies (beauty salons) that may have only the headquarters unit and/or the headquarters unit and the subsidiary units. All two types will be multi-users and several modules, some being: customer registration, Supplier Registration, professional registration, Registration of products and services, schedule, inventory control, financial, sales and purchases.

Who has or has had experience with this type of multi tenancy architecture, what do you have to advise me regarding the use of the database? Because the question is: use the same database for all customers or set up a new database for each new customer?

Author: Bruno Augusto, 2014-05-09

3 answers

I recently worked on a multi-tenant project. I did not participate in the architecture decision; I only did maintenance and development with the project in an advanced stage.

There was a "central" database, which even had the "tenants" register itself. And, for each tenant, a new database was created among the procedures at the time of its inclusion.

The architecture seemed very good to me, and the code was also well structured, well coherent, without confusion. From this my brief interaction with this system, I would not recommend using the same database for all customers. The "one database for each client" separation makes the entire application development much simpler.

Each case is a case, but the suggestion comes from the contact with a real application: a "central" database and a database for each client is a good request.

P.S.-of course the tools you have and your experience with them it will be important to manage this complexity. In the case, the application was in Symfony 2 (which I particularly do not like), but I imagine the same architecture performed in Laravel 4 (which I particularly like) without much difficulty.

 7
Author: J. Bruni, 2014-05-14 01:10:50

Use the same database for all customers or set up a new database for each new customer?

What You should analyze:

1-How many potential users do you expect to reach ?

It is complicated to estimate the quantity with authority, but I think what in terms of orders of magnitude would it be: thousands? tens of thousands? more? If it is a high magnitude of users it would be advisable to use the shared approach.

2 - how much space storage you expect data from the average users to occupy?

If you expect these users will have to store large amounts of data the separate database approach is probably the best.

3 - how many concurrent users do you expect to support ?

The higher the number, the more suitable the insulation would be to meet the requirements.

4-you expect to offer any value-added per-tenant services such as backup per-tenant and restore backup?

Such services are easier to offer through a more isolated approach.

Of course with the growth of some technologies the support/ storage of information can be easily questioned, but in short this is it!

Parsing your problem:

The application will serve companies (beauty salons) that may have only

The head office unit and / or the head office unit and the subsidiary units. All two types will be multi-user and several modules, some being: Customer registration, supplier registration, customer registration Professionals, Registration of products and services, Agenda, control of Stock, Financial, sales and purchases.

If you understood everything I explained above your doubts will be as follows:

Companies will ask for additional service as backup or have several other features that do not make sense to have in another beauty salon (related to companies selling a service and customizations for each client.)?

Then it will be recommended to isolate the database, otherwise you prefer the use of a shared base.

Reference: How to create a multi-tenant database with shared table structures?

 1
Author: Gabriel Rodrigues, 2017-05-23 12:37:23

Separate banks gives you more security. But it is easier to implement an approach using the same bank. If you can, go from separate banks.

 0
Author: Matheus de Alencar, 2014-10-01 01:35:06