#1 2017-09-13 08:58:36

Bram
Member
Registered: 2017-08-04
Posts: 5

mORMot in a multitenant application

We develop an ERP application that's currently deployed on-premises. It consists of a thin-client and a monolithic backend, which we are looking to upgrade (and probably convert to microservices) with mORMot or another REST solution. A next step would be to make the backend multi-tenant, so one backend server can handle sessions for users of multiple customers. Each customer has his own database (and several users).

Because the server is stateless (and the request specifies which tenants it belongs to), each request must get a database-connection for the database for this tenant. For services defined via interfaces we can switch the database-connection ourselves, but how would that work for the ORM? All examples I've seen already bind the database before using the ORM.

Another question: because we want to serve multiple tenants with one backend, our users would have to authenticate with company/user/password. The examples I've seen all authenticate with only user and password. Can we use your default authentication with the added "company"?

How do other companies with multi-tenant solutions tackle these issues, what are the best practices?

Thanks for your help!

Offline

#2 2017-09-13 10:07:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: mORMot in a multitenant application

You may create a TSQLRestServer for each user, each one with its own model, so its own "root" URI identifier.
I would recommend using SQlite3 as database engine - very fast, and easy to backup: one single file per customer.

With this pattern, the user company could simply be the model "root", i.e. the customer.

How many customer/company/database are you dealing with?
By default, our SQLite3 engine will use 40MB of RAM for cache, so no more than 40-50 TSQLRestServerDB will be allowed for a 32-bit process- but you can compile as Win64 or decrease the value of the cache size.

Online

#3 2017-09-13 12:30:55

Bram
Member
Registered: 2017-08-04
Posts: 5

Re: mORMot in a multitenant application

Thanks for your reply. We are dealing with a few hundred customers (say 300), with one database each. Database size varies from 50mb for smaller companies that just started, to 20gb for some big customers that have been using our software for years. The average customer has 5-10 simultaneous users. Our application currently uses Microsoft SQL Server, which we would prefer to keep using.

Offline

Board footer

Powered by FluxBB