Currently I am facing a technological decision to be made and personally am not able to find the solution myself.
I am currently in progress to develop a multiple-tenant database.
The structure would be the following:
- There is one core database which saves data and relations about specific tenants
- There are multiple tenant database instances(from a query in the core database, it is determined which tenant id I should be connecting to)
- Each tenant is on a separate database instance(on a separate server)
- Each tenant has specific data which should not be accessible by none of other tenants
- Each database would preferably be in mySQL(but if there are better options, I am open to suggestions)
- Backend is written in koa framework
- The database models are different in the core database and tenant databases
- Each tenant database's largest table could be around 1 mil records(without auditing)
- Optimistically the amount of tenants could grow up to 50
Additional data about the project:
- All of project's data is available for the owner
- Each client will have data available for their own tenant
- Each tenant will have their own website
- Database structure remains the same for each tenant
- Project is mainly a logistics service, which's data is segregated for each different region
The question:
Is this the correct approach to design a multi-tenant architecture or should there be a redesign in the architecture?
If multi-tenant with multiple servers are possible - is there a preferable tool/technology stack that should be done? (Would love to know more specifically about this)
It would be preferred to use an ORM. I am currently trying to use Sequelize but i am facing problems already at early stage(Multiple databases can't share the same models, management of multiple connections).
The ideal goal would be the possibility of adding additional tenants without much additional configuration.
EDIT: - The databases would be currently hosted in Azure, but we'd prefer the option that they can be migrated away if it becomes a requirement